Skip to content

Commit

Permalink
Merge pull request #31 from jglick/BaseEmptyView.equals-JENKINS-32782
Browse files Browse the repository at this point in the history
[JENKINS-32782] Empty view did not show delete link
  • Loading branch information
jglick committed Mar 11, 2016
2 parents 1fdf9e6 + 59526c1 commit 2c30f50
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/main/java/jenkins/branch/BaseEmptyView.java
Expand Up @@ -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();
}

/**
Expand Down
11 changes: 11 additions & 0 deletions src/test/java/jenkins/branch/OrganizationFolderTest.java
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {}

Expand Down

0 comments on commit 2c30f50

Please sign in to comment.