Skip to content
Permalink
Browse files

Merge pull request #21 from jglick/inside-folder-JENKINS-31949

[JENKINS-31949] CustomOrganizationFolderDescriptor.HideGeneric did not work inside folders
  • Loading branch information...
jglick committed Dec 8, 2015
2 parents 2338396 + 4ec64f1 commit 214823ff10288cce19dca252335b4d555aeacd6d
@@ -34,6 +34,7 @@
import hudson.model.TopLevelItem;
import hudson.model.TopLevelItemDescriptor;
import hudson.model.View;
import hudson.model.ViewGroup;
import jenkins.scm.api.SCMNavigatorDescriptor;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
@@ -92,7 +93,7 @@ public static void addSpecificDescriptors() {

@Override
public boolean filter(Object context, Descriptor descriptor) {
if (descriptor instanceof OrganizationFolder.DescriptorImpl && context instanceof View) {
if (descriptor instanceof OrganizationFolder.DescriptorImpl && (context instanceof View || context instanceof ViewGroup)) {
return false;
}
return true;
@@ -24,6 +24,7 @@

package jenkins.branch;

import com.cloudbees.hudson.plugins.folder.Folder;
import hudson.ExtensionList;
import hudson.model.DescriptorVisibilityFilter;
import hudson.model.Items;
@@ -40,6 +41,7 @@
import static org.junit.Assert.*;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.TestExtension;

@@ -86,6 +88,19 @@ public void someNavigatorSomeFactoryInstalled() throws Exception {
@TestExtension("someNavigatorSomeFactoryInstalled")
public static class SomeNavigatorSomeFactoryInstalledDescriptor2 extends OrganizationFolderTest.MockFactoryDescriptor {}

@Issue("JENKINS-31949")
@Test
public void insideFolder() throws Exception {
Folder folder = r.jenkins.createProject(Folder.class, "d");
List<String> names = new ArrayList<String>();
for (TopLevelItemDescriptor d : DescriptorVisibilityFilter.apply(folder, Items.all())) {
if (d.clazz == OrganizationFolder.class || d instanceof CustomOrganizationFolderDescriptor) {
names.add(d.getDisplayName());
}
}
assertEquals(Collections.emptyList(), names);
}

private static class MockNavigator extends SCMNavigator {
@Override
public void visitSources(SCMSourceObserver observer) throws IOException, InterruptedException {}

0 comments on commit 214823f

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