Skip to content
Permalink
Browse files

Merge pull request #31 from jglick/BaseEmptyView.equals-JENKINS-32782

[JENKINS-32782] Empty view did not show delete link
  • Loading branch information...
jglick committed Mar 11, 2016
2 parents 1fdf9e6 + 59526c1 commit 2c30f50f0245294fe215f2e0c5158ff4397cb108
@@ -28,7 +28,25 @@ public BaseEmptyView(ViewGroup owner) {
*/
@Override
public boolean isDefault() {
return true; // this renders as a top-level page
// TODO might be better for the base implementation in View to be written this way rather than using ==
return equals(getOwnerPrimaryView());
}

/**
* Equal to any view of the same class and owner.
* {@inheritDoc}
*/
@Override
public final boolean equals(Object obj) {
return obj != null && obj.getClass() == getClass() && ((BaseEmptyView) obj).owner == owner;
}

/**
* {@inheritDoc}
*/
@Override
public final int hashCode() {
return owner == null ? 0 : owner.hashCode();
}

/**
@@ -26,6 +26,7 @@

import hudson.model.ItemGroup;
import hudson.model.TaskListener;
import hudson.model.View;
import jenkins.branch.harness.MultiBranchImpl;
import jenkins.scm.api.SCMNavigator;
import jenkins.scm.impl.SingleSCMNavigator;
@@ -93,6 +94,16 @@ public void indexChildrenOnOrganizationFolderIndex() throws Exception {
waitForLogFileMessage("Indexing multibranch project: stuff", logs);
}

@Issue("JENKINS-32782")
@Test
public void emptyViewEquality() throws Exception {
OrganizationFolder top = r.jenkins.createProject(OrganizationFolder.class, "top");
View emptyView = top.getPrimaryView();
assertEquals("Welcome", emptyView.getViewName());
assertEquals(emptyView, top.getPrimaryView());
assertTrue(emptyView.isDefault());
}

@TestExtension
public static class ConfigRoundTripDescriptor extends MockFactoryDescriptor {}

0 comments on commit 2c30f50

Please sign in to comment.
You can’t perform that action at this time.