Skip to content

Commit

Permalink
[JENKINS-74795] createItem API should not assign new jobs to default …
Browse files Browse the repository at this point in the history
…view

Behavior in 2.474 and earlier was to not assign new jobs to the default
view.  Unfortunately, there was no automated test to check that case.
  • Loading branch information
MarkEWaite committed Nov 3, 2024
1 parent 7aee661 commit 081580a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 15 deletions.
4 changes: 2 additions & 2 deletions core/src/main/java/hudson/model/ListView.java
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,8 @@ private boolean needToAddToCurrentView(StaplerRequest2 req) throws ServletExcept
JSONObject form = req.getSubmittedForm();
return form.has("addToCurrentView") && form.getBoolean("addToCurrentView");
} else {
// Submitted via API
return true;
// Submitted via API - JENKINS-74975
return false;
}
}

Expand Down
11 changes: 1 addition & 10 deletions test/src/test/java/hudson/jobs/CreateItemTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,10 @@
import hudson.model.ItemGroup;
import hudson.model.ListView;
import hudson.model.listeners.ItemListener;
import hudson.util.VersionNumber;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URL;
import java.text.MessageFormat;
import jenkins.model.Jenkins;
import org.htmlunit.HttpMethod;
import org.htmlunit.Page;
import org.htmlunit.WebRequest;
Expand Down Expand Up @@ -114,14 +112,7 @@ public void testCreateItemDoesNotPopulateDefaultView() throws Exception {

// Confirm new job is not visible in default view
assertTrue(aView.isDefault()); // a-view is still the default view
VersionNumber jenkinsVersion = Jenkins.getVersion();
if (jenkinsVersion == null || jenkinsVersion.isOlderThan(new VersionNumber("2.475"))) {
// TODO: When JENKINS-74795 is fixed, this assertion will pass
assertThat(aView.getItems(), containsInAnyOrder(aJob));
} else {
// TODO: Until JENKINS-74795 is fixed, this assertion passes (a bug)
assertThat(aView.getItems(), containsInAnyOrder(aJob, b2Job));
}
assertThat(aView.getItems(), containsInAnyOrder(aJob));
}

@Issue("JENKINS-31235")
Expand Down
4 changes: 1 addition & 3 deletions test/src/test/java/hudson/model/ItemsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
Expand All @@ -41,7 +40,6 @@
import hudson.cli.CopyJobCommand;
import hudson.cli.CreateJobCommand;
import hudson.security.ACL;
import hudson.util.VersionNumber;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.net.HttpURLConnection;
Expand Down Expand Up @@ -210,7 +208,7 @@ private void createPrimaryView() throws Exception {
}

/* JENKINS-74795 notes that new items created through the REST API
* are made visible in the default view with 2.475 and newer.
* are made visible in the default view with 2.475-2.483.
* They were not made visible in the default view with 2.474 and
* earlier.
*/
Expand Down

0 comments on commit 081580a

Please sign in to comment.