Skip to content

Commit

Permalink
Merge branch 'master' into 11-to-17
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkEWaite committed Dec 20, 2024
2 parents 8b3c49c + 3ffcda9 commit 48d5311
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public String doText(
Run<?, ?> run = null;

if (project != null && build != null) {
// as the user might have ViewStatus permission only (e.g. as anonymous) we get get the
// as the user might have ViewStatus permission only (e.g. as anonymous) we get the
// project impersonate and check for permission after getting the project
try (ACLContext ctx = ACL.as2(ACL.SYSTEM2)) {
for (String token : build.split(",")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,39 @@ public void testGetDisplayName() throws IOException {
private boolean isWindows() {
return File.pathSeparatorChar == ';';
}

@Test
public void doText_shouldReturnMissingQueryParameterWhenJobIsNull() throws IOException {
PublicBuildStatusAction action = new PublicBuildStatusAction();
String result = action.doText(null, null, null, "123");
assertThat(result, is("Missing query parameter: job"));
}

@Test
public void doText_shouldReturnProjectIconWhenJobHasNotRun() throws IOException {
PublicBuildStatusAction action = new PublicBuildStatusAction();
String result = action.doText(null, null, job.getName(), null);
assertThat(result, is(job.getIconColor().getDescription()));
assertThat(result, is("Not built"));
}

@Test
public void doText_shouldReturnProjectIconColorDescription() throws Exception {
Run<?, ?> build = job.scheduleBuild2(0).get();
j.assertBuildStatusSuccess(build);
String result =
new PublicBuildStatusAction().doText(null, null, job.getName(), String.valueOf(build.getNumber()));
assertThat(result, is(job.getIconColor().getDescription()));
assertThat(result, is("Success"));
}

@Test
public void doText_shouldReturnRunIconColorDescription() throws Exception {
Run<?, ?> build = job.scheduleBuild2(0).get();
j.assertBuildStatusSuccess(build);
String result =
new PublicBuildStatusAction().doText(null, null, job.getName(), String.valueOf(build.getNumber()));
assertThat(result, is(build.getIconColor().getDescription()));
assertThat(result, is("Success"));
}
}

0 comments on commit 48d5311

Please sign in to comment.