@@ -23,7 +23,11 @@ def test_accepted_urls
23
23
"https://kernel.org/pub/scm/git/git.git" ,
24
24
"https://kernel.org:8080/pub/scm/git/git.git" ,
25
25
"git://kernel.org/~foo/git.git" ,
26
- "http://git.onerussian.com/pub/deb/impose+.git"
26
+ "http://git.onerussian.com/pub/deb/impose+.git" ,
27
+ "https://Person@github.com/Person/some_repo.git" ,
28
+ "http://Person@github.com/Person/some_repo.git" ,
29
+ "https://github.com/Person/some_repo" ,
30
+ "http://github.com/Person/some_repo"
27
31
] . each do |url |
28
32
git = GitAdapter . new ( :url => url )
29
33
assert !git . validate_url
@@ -41,32 +45,49 @@ def test_guess_forge
41
45
assert_equal 'kernel.org' , git . guess_forge
42
46
end
43
47
44
- def test_read_only_url
45
- assert_equal nil , GitAdapter . new ( :url => nil ) . read_only_url
46
- assert_equal '' , GitAdapter . new ( :url => '' ) . read_only_url
47
- assert_equal 'foo' , GitAdapter . new ( :url => 'foo' ) . read_only_url
48
+ def test_normalize_url
49
+ assert_equal nil , GitAdapter . new ( :url => nil ) . normalize_url
50
+ assert_equal '' , GitAdapter . new ( :url => '' ) . normalize_url
51
+ assert_equal 'foo' , GitAdapter . new ( :url => 'foo' ) . normalize_url
48
52
49
53
# A non-Github URL: no change
50
54
assert_equal 'git://kernel.org/pub/scm/git/git.git' ,
51
- GitAdapter . new ( :url => 'git://kernel.org/pub/scm/git/git.git' ) . read_only_url
55
+ GitAdapter . new ( :url => 'git://kernel.org/pub/scm/git/git.git' ) . normalize_url
52
56
53
57
# A Github read-write URL: converted to read-only
54
58
assert_equal 'git://github.com/robinluckey/ohcount.git' ,
55
- GitAdapter . new ( :url => 'https://robinluckey@github.com/robinluckey/ohcount.git' ) . read_only_url
59
+ GitAdapter . new ( :url => 'https://robinluckey@github.com/robinluckey/ohcount.git' ) . normalize_url
56
60
57
61
# A Github read-write URL: converted to read-only
58
62
assert_equal 'git://github.com/robinluckey/ohcount.git' ,
59
- GitAdapter . new ( :url => 'git@github.com:robinluckey/ohcount.git' ) . read_only_url
63
+ GitAdapter . new ( :url => 'git@github.com:robinluckey/ohcount.git' ) . normalize_url
60
64
61
65
# A Github read-only URL: no change
62
66
assert_equal 'git://github.com/robinluckey/ohcount.git' ,
63
- GitAdapter . new ( :url => 'git@github.com:robinluckey/ohcount.git' ) . read_only_url
67
+ GitAdapter . new ( :url => 'git@github.com:robinluckey/ohcount.git' ) . normalize_url
64
68
end
65
69
66
70
def test_normalize_converts_to_read_only
67
- git = GitAdapter . new ( :url => 'https://robinluckey@github.com/robinluckey/ohcount.git' )
68
- git . normalize
69
- assert_equal 'git://github.com/robinluckey/ohcount.git' , git . url
71
+ normalize_url_test ( 'https://robinluckey@github.com/robinluckey/ohcount.git' , 'git://github.com/robinluckey/ohcount.git' )
72
+ end
73
+
74
+ def test_normalize_handles_https_with_user_at_github_format
75
+ normalize_url_test ( 'http://Person@github.com/Person/something.git' , 'git://github.com/Person/something.git' )
76
+ end
77
+
78
+ def test_normalize_handles_https_web_url
79
+ normalize_url_test ( 'https://github.com/Person/something' , 'git://github.com/Person/something' )
70
80
end
81
+
82
+ def test_normalize_handles_http_web_url
83
+ normalize_url_test ( 'http://github.com/Person/something' , 'git://github.com/Person/something' )
84
+ end
85
+
86
+ private
87
+ def normalize_url_test ( url , result_url )
88
+ git = GitAdapter . new ( :url => url )
89
+ git . normalize
90
+ assert_equal result_url , git . url
91
+ end
71
92
end
72
93
end
0 commit comments