Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #211 from MarkEWaite/master-add-browser-url-round-…
…trip-test

Test [Fixed JENKINS-22604] - browser setting is lost when config is saved
  • Loading branch information
MarkEWaite committed Mar 20, 2014
2 parents b46de67 + 6feb17b commit b2a731e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Expand Up @@ -273,6 +273,12 @@
<version>1.9.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.3</version>
<scope>test</scope>
</dependency>


<dependency><!-- we contribute AbstractBuildParameters for Git if it's available -->
Expand Down
26 changes: 26 additions & 0 deletions src/test/java/hudson/plugins/git/GitSCMTest.java
Expand Up @@ -4,6 +4,8 @@
import hudson.FilePath;
import hudson.model.*;
import hudson.plugins.git.GitSCM.BuildChooserContextImpl;
import hudson.plugins.git.browser.GitRepositoryBrowser;
import hudson.plugins.git.browser.GithubWeb;
import hudson.plugins.git.extensions.GitSCMExtension;
import hudson.plugins.git.extensions.impl.AuthorInChangelog;
import hudson.plugins.git.extensions.impl.LocalBranch;
Expand Down Expand Up @@ -976,6 +978,30 @@ public void buildEnvironmentFor(Run r, EnvVars envs, TaskListener listener) thro
envs.put("CAT","");
}
}

private List<UserRemoteConfig> createRepoList(String url) {
List<UserRemoteConfig> repoList = new ArrayList<UserRemoteConfig>();
repoList.add(new UserRemoteConfig(url, null, null, null));
return repoList;
}

/**
* Makes sure that git browser URL is preserved across config round trip.
*/
@Bug(22604)
public void testConfigRoundtripURLPreserved() throws Exception {
FreeStyleProject p = createFreeStyleProject();
final String url = "https://github.com/jenkinsci/jenkins";
GitRepositoryBrowser browser = new GithubWeb(url);
GitSCM scm = new GitSCM(createRepoList(url),
Collections.singletonList(new BranchSpec("")),
false, Collections.<SubmoduleConfig>emptyList(),
browser, null, null);
p.setScm(scm);
configRoundtrip(p);
assertEqualDataBoundBeans(scm,p.getScm());
}

/**
* Makes sure that the configuration form works.
*/
Expand Down

0 comments on commit b2a731e

Please sign in to comment.