-
Notifications
You must be signed in to change notification settings - Fork 394
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use
TransientActionFactory
instead of `GithubProjectProperty.getJob…
…Actions`. This makes the "GitHub" link also show up for Workflow projects.
- Loading branch information
1 parent
2b94ad7
commit fd19ca8
Showing
3 changed files
with
70 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/test/java/com/coravy/hudson/plugins/github/GithubLinkActionFactoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.coravy.hudson.plugins.github; | ||
|
||
import static org.hamcrest.Matchers.is; | ||
import static org.hamcrest.Matchers.equalTo; | ||
import static org.hamcrest.Matchers.empty; | ||
import static org.junit.Assert.assertThat; | ||
|
||
import java.io.IOException; | ||
import java.util.Collection; | ||
|
||
import org.jenkinsci.plugins.workflow.job.WorkflowJob; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
|
||
import com.coravy.hudson.plugins.github.GithubLinkAction.GithubLinkActionFactory; | ||
|
||
import hudson.model.Action; | ||
|
||
public class GithubLinkActionFactoryTest { | ||
@Rule | ||
public JenkinsRule j = new JenkinsRule(); | ||
|
||
public GithubLinkActionFactory factory = new GithubLinkActionFactory(); | ||
|
||
@Test | ||
public void shouldCreateGithubLinkActionForJobWithGithubProjectProperty() throws IOException { | ||
WorkflowJob p = j.jenkins.createProject(WorkflowJob.class, "p"); | ||
p.addProperty(new GithubProjectProperty("https://github.com/jenkinsci/github-plugin/")); | ||
|
||
Collection<? extends Action> actions = factory.createFor(p); | ||
assertThat(actions.size(), is(equalTo(1))); | ||
|
||
GithubLinkAction action = (GithubLinkAction) actions.iterator().next(); | ||
assertThat(action.getUrlName(), is(equalTo("https://github.com/jenkinsci/github-plugin/"))); | ||
} | ||
|
||
@Test | ||
public void shouldNotCreateGithubLinkActionForJobWithoutGithubProjectProperty() throws IOException { | ||
WorkflowJob p = j.jenkins.createProject(WorkflowJob.class, "p"); | ||
|
||
Collection<? extends Action> actions = factory.createFor(p); | ||
assertThat(actions, is(empty())); | ||
} | ||
} |