Skip to content

Commit b2a731e

Browse files
committed
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
2 parents b46de67 + 6feb17b commit b2a731e

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

pom.xml

+6
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,12 @@
273273
<version>1.9.5</version>
274274
<scope>test</scope>
275275
</dependency>
276+
<dependency>
277+
<groupId>org.apache.httpcomponents</groupId>
278+
<artifactId>httpclient</artifactId>
279+
<version>4.3.3</version>
280+
<scope>test</scope>
281+
</dependency>
276282

277283

278284
<dependency><!-- we contribute AbstractBuildParameters for Git if it's available -->

src/test/java/hudson/plugins/git/GitSCMTest.java

+26
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import hudson.FilePath;
55
import hudson.model.*;
66
import hudson.plugins.git.GitSCM.BuildChooserContextImpl;
7+
import hudson.plugins.git.browser.GitRepositoryBrowser;
8+
import hudson.plugins.git.browser.GithubWeb;
79
import hudson.plugins.git.extensions.GitSCMExtension;
810
import hudson.plugins.git.extensions.impl.AuthorInChangelog;
911
import hudson.plugins.git.extensions.impl.LocalBranch;
@@ -976,6 +978,30 @@ public void buildEnvironmentFor(Run r, EnvVars envs, TaskListener listener) thro
976978
envs.put("CAT","");
977979
}
978980
}
981+
982+
private List<UserRemoteConfig> createRepoList(String url) {
983+
List<UserRemoteConfig> repoList = new ArrayList<UserRemoteConfig>();
984+
repoList.add(new UserRemoteConfig(url, null, null, null));
985+
return repoList;
986+
}
987+
988+
/**
989+
* Makes sure that git browser URL is preserved across config round trip.
990+
*/
991+
@Bug(22604)
992+
public void testConfigRoundtripURLPreserved() throws Exception {
993+
FreeStyleProject p = createFreeStyleProject();
994+
final String url = "https://github.com/jenkinsci/jenkins";
995+
GitRepositoryBrowser browser = new GithubWeb(url);
996+
GitSCM scm = new GitSCM(createRepoList(url),
997+
Collections.singletonList(new BranchSpec("")),
998+
false, Collections.<SubmoduleConfig>emptyList(),
999+
browser, null, null);
1000+
p.setScm(scm);
1001+
configRoundtrip(p);
1002+
assertEqualDataBoundBeans(scm,p.getScm());
1003+
}
1004+
9791005
/**
9801006
* Makes sure that the configuration form works.
9811007
*/

0 commit comments

Comments
 (0)