Skip to content

Commit

Permalink
[JENKINS-72443] Do not show copy option without visible items (#8763)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Beck <[email protected]>
  • Loading branch information
daniel-beck and daniel-beck authored Dec 13, 2023
1 parent 0a94979 commit 7df7ae4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/main/resources/hudson/model/View/newJob.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ THE SOFTWARE.

<div id="items" class="categories flat" role="radiogroup" aria-labelledby="Items" data-valid="false" />

<j:if test="${!empty(app.itemMap)}">
<j:if test="${!empty(app.items)}">
<div class="item-copy">
<p class="description">${%CopyOption.description}</p>
<div class="add-item-copy">
Expand Down
32 changes: 32 additions & 0 deletions test/src/test/java/jenkins/model/NewJobCopyFromTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package jenkins.model;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;

import hudson.model.Item;
import java.io.IOException;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.MockAuthorizationStrategy;
import org.xml.sax.SAXException;

public class NewJobCopyFromTest {
@Rule
public JenkinsRule j = new JenkinsRule();

@Test
public void checkLabel() throws IOException, SAXException {
try (JenkinsRule.WebClient wc = j.createWebClient()) {
// no items - validate assertion
assertThat(wc.goTo("newJob").getElementById("from"), is(nullValue()));

// actual test
j.createFreeStyleProject();
j.jenkins.setSecurityRealm(j.createDummySecurityRealm());
j.jenkins.setAuthorizationStrategy(new MockAuthorizationStrategy().grant(Item.CREATE, Jenkins.READ).everywhere().toEveryone());
assertThat(wc.goTo("newJob").getElementById("from"), is(nullValue()));
}
}
}

0 comments on commit 7df7ae4

Please sign in to comment.