1 | NO CONTENT: modified file, binary diff hidden |
|
NO CONTENT: modified file, binary diff hidden |
@@ -1,493 +1,493 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | require File.expand_path('../../test_helper', __FILE__) |
|
18 | require File.expand_path('../../test_helper', __FILE__) | |
19 |
|
19 | |||
20 | class RepositoriesGitControllerTest < ActionController::TestCase |
|
20 | class RepositoriesGitControllerTest < ActionController::TestCase | |
21 | tests RepositoriesController |
|
21 | tests RepositoriesController | |
22 |
|
22 | |||
23 | fixtures :projects, :users, :roles, :members, :member_roles, |
|
23 | fixtures :projects, :users, :roles, :members, :member_roles, | |
24 | :repositories, :enabled_modules |
|
24 | :repositories, :enabled_modules | |
25 |
|
25 | |||
26 | REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s |
|
26 | REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s | |
27 | REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin? |
|
27 | REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin? | |
28 | PRJ_ID = 3 |
|
28 | PRJ_ID = 3 | |
29 | CHAR_1_HEX = "\xc3\x9c" |
|
29 | CHAR_1_HEX = "\xc3\x9c" | |
30 |
NUM_REV = 2 |
|
30 | NUM_REV = 28 | |
31 |
|
31 | |||
32 | ## Git, Mercurial and CVS path encodings are binary. |
|
32 | ## Git, Mercurial and CVS path encodings are binary. | |
33 | ## Subversion supports URL encoding for path. |
|
33 | ## Subversion supports URL encoding for path. | |
34 | ## Redmine Mercurial adapter and extension use URL encoding. |
|
34 | ## Redmine Mercurial adapter and extension use URL encoding. | |
35 | ## Git accepts only binary path in command line parameter. |
|
35 | ## Git accepts only binary path in command line parameter. | |
36 | ## So, there is no way to use binary command line parameter in JRuby. |
|
36 | ## So, there is no way to use binary command line parameter in JRuby. | |
37 | JRUBY_SKIP = (RUBY_PLATFORM == 'java') |
|
37 | JRUBY_SKIP = (RUBY_PLATFORM == 'java') | |
38 | JRUBY_SKIP_STR = "TODO: This test fails in JRuby" |
|
38 | JRUBY_SKIP_STR = "TODO: This test fails in JRuby" | |
39 |
|
39 | |||
40 | def setup |
|
40 | def setup | |
41 | @ruby19_non_utf8_pass = |
|
41 | @ruby19_non_utf8_pass = | |
42 | (RUBY_VERSION >= '1.9' && Encoding.default_external.to_s != 'UTF-8') |
|
42 | (RUBY_VERSION >= '1.9' && Encoding.default_external.to_s != 'UTF-8') | |
43 |
|
43 | |||
44 | User.current = nil |
|
44 | User.current = nil | |
45 | @project = Project.find(PRJ_ID) |
|
45 | @project = Project.find(PRJ_ID) | |
46 | @repository = Repository::Git.create( |
|
46 | @repository = Repository::Git.create( | |
47 | :project => @project, |
|
47 | :project => @project, | |
48 | :url => REPOSITORY_PATH, |
|
48 | :url => REPOSITORY_PATH, | |
49 | :path_encoding => 'ISO-8859-1' |
|
49 | :path_encoding => 'ISO-8859-1' | |
50 | ) |
|
50 | ) | |
51 | assert @repository |
|
51 | assert @repository | |
52 | @char_1 = CHAR_1_HEX.dup |
|
52 | @char_1 = CHAR_1_HEX.dup | |
53 | if @char_1.respond_to?(:force_encoding) |
|
53 | if @char_1.respond_to?(:force_encoding) | |
54 | @char_1.force_encoding('UTF-8') |
|
54 | @char_1.force_encoding('UTF-8') | |
55 | end |
|
55 | end | |
56 |
|
56 | |||
57 | Setting.default_language = 'en' |
|
57 | Setting.default_language = 'en' | |
58 | end |
|
58 | end | |
59 |
|
59 | |||
60 | if File.directory?(REPOSITORY_PATH) |
|
60 | if File.directory?(REPOSITORY_PATH) | |
61 | def test_get_new |
|
61 | def test_get_new | |
62 | @request.session[:user_id] = 1 |
|
62 | @request.session[:user_id] = 1 | |
63 | @project.repository.destroy |
|
63 | @project.repository.destroy | |
64 | get :new, :project_id => 'subproject1', :repository_scm => 'Git' |
|
64 | get :new, :project_id => 'subproject1', :repository_scm => 'Git' | |
65 | assert_response :success |
|
65 | assert_response :success | |
66 | assert_template 'new' |
|
66 | assert_template 'new' | |
67 | assert_kind_of Repository::Git, assigns(:repository) |
|
67 | assert_kind_of Repository::Git, assigns(:repository) | |
68 | assert assigns(:repository).new_record? |
|
68 | assert assigns(:repository).new_record? | |
69 | end |
|
69 | end | |
70 |
|
70 | |||
71 | def test_browse_root |
|
71 | def test_browse_root | |
72 | assert_equal 0, @repository.changesets.count |
|
72 | assert_equal 0, @repository.changesets.count | |
73 | @repository.fetch_changesets |
|
73 | @repository.fetch_changesets | |
74 | @project.reload |
|
74 | @project.reload | |
75 | assert_equal NUM_REV, @repository.changesets.count |
|
75 | assert_equal NUM_REV, @repository.changesets.count | |
76 |
|
76 | |||
77 | get :show, :id => PRJ_ID |
|
77 | get :show, :id => PRJ_ID | |
78 | assert_response :success |
|
78 | assert_response :success | |
79 | assert_template 'show' |
|
79 | assert_template 'show' | |
80 | assert_not_nil assigns(:entries) |
|
80 | assert_not_nil assigns(:entries) | |
81 | assert_equal 9, assigns(:entries).size |
|
81 | assert_equal 9, assigns(:entries).size | |
82 | assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'} |
|
82 | assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'} | |
83 | assert assigns(:entries).detect {|e| e.name == 'this_is_a_really_long_and_verbose_directory_name' && e.kind == 'dir'} |
|
83 | assert assigns(:entries).detect {|e| e.name == 'this_is_a_really_long_and_verbose_directory_name' && e.kind == 'dir'} | |
84 | assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'} |
|
84 | assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'} | |
85 | assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'} |
|
85 | assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'} | |
86 | assert assigns(:entries).detect {|e| e.name == 'copied_README' && e.kind == 'file'} |
|
86 | assert assigns(:entries).detect {|e| e.name == 'copied_README' && e.kind == 'file'} | |
87 | assert assigns(:entries).detect {|e| e.name == 'new_file.txt' && e.kind == 'file'} |
|
87 | assert assigns(:entries).detect {|e| e.name == 'new_file.txt' && e.kind == 'file'} | |
88 | assert assigns(:entries).detect {|e| e.name == 'renamed_test.txt' && e.kind == 'file'} |
|
88 | assert assigns(:entries).detect {|e| e.name == 'renamed_test.txt' && e.kind == 'file'} | |
89 | assert assigns(:entries).detect {|e| e.name == 'filemane with spaces.txt' && e.kind == 'file'} |
|
89 | assert assigns(:entries).detect {|e| e.name == 'filemane with spaces.txt' && e.kind == 'file'} | |
90 | assert assigns(:entries).detect {|e| e.name == ' filename with a leading space.txt ' && e.kind == 'file'} |
|
90 | assert assigns(:entries).detect {|e| e.name == ' filename with a leading space.txt ' && e.kind == 'file'} | |
91 | assert_not_nil assigns(:changesets) |
|
91 | assert_not_nil assigns(:changesets) | |
92 | assert assigns(:changesets).size > 0 |
|
92 | assert assigns(:changesets).size > 0 | |
93 | end |
|
93 | end | |
94 |
|
94 | |||
95 | def test_browse_branch |
|
95 | def test_browse_branch | |
96 | assert_equal 0, @repository.changesets.count |
|
96 | assert_equal 0, @repository.changesets.count | |
97 | @repository.fetch_changesets |
|
97 | @repository.fetch_changesets | |
98 | @project.reload |
|
98 | @project.reload | |
99 | assert_equal NUM_REV, @repository.changesets.count |
|
99 | assert_equal NUM_REV, @repository.changesets.count | |
100 | get :show, :id => PRJ_ID, :rev => 'test_branch' |
|
100 | get :show, :id => PRJ_ID, :rev => 'test_branch' | |
101 | assert_response :success |
|
101 | assert_response :success | |
102 | assert_template 'show' |
|
102 | assert_template 'show' | |
103 | assert_not_nil assigns(:entries) |
|
103 | assert_not_nil assigns(:entries) | |
104 | assert_equal 4, assigns(:entries).size |
|
104 | assert_equal 4, assigns(:entries).size | |
105 | assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'} |
|
105 | assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'} | |
106 | assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'} |
|
106 | assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'} | |
107 | assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'} |
|
107 | assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'} | |
108 | assert assigns(:entries).detect {|e| e.name == 'test.txt' && e.kind == 'file'} |
|
108 | assert assigns(:entries).detect {|e| e.name == 'test.txt' && e.kind == 'file'} | |
109 | assert_not_nil assigns(:changesets) |
|
109 | assert_not_nil assigns(:changesets) | |
110 | assert assigns(:changesets).size > 0 |
|
110 | assert assigns(:changesets).size > 0 | |
111 | end |
|
111 | end | |
112 |
|
112 | |||
113 | def test_browse_tag |
|
113 | def test_browse_tag | |
114 | assert_equal 0, @repository.changesets.count |
|
114 | assert_equal 0, @repository.changesets.count | |
115 | @repository.fetch_changesets |
|
115 | @repository.fetch_changesets | |
116 | @project.reload |
|
116 | @project.reload | |
117 | assert_equal NUM_REV, @repository.changesets.count |
|
117 | assert_equal NUM_REV, @repository.changesets.count | |
118 | [ |
|
118 | [ | |
119 | "tag00.lightweight", |
|
119 | "tag00.lightweight", | |
120 | "tag01.annotated", |
|
120 | "tag01.annotated", | |
121 | ].each do |t1| |
|
121 | ].each do |t1| | |
122 | get :show, :id => PRJ_ID, :rev => t1 |
|
122 | get :show, :id => PRJ_ID, :rev => t1 | |
123 | assert_response :success |
|
123 | assert_response :success | |
124 | assert_template 'show' |
|
124 | assert_template 'show' | |
125 | assert_not_nil assigns(:entries) |
|
125 | assert_not_nil assigns(:entries) | |
126 | assert assigns(:entries).size > 0 |
|
126 | assert assigns(:entries).size > 0 | |
127 | assert_not_nil assigns(:changesets) |
|
127 | assert_not_nil assigns(:changesets) | |
128 | assert assigns(:changesets).size > 0 |
|
128 | assert assigns(:changesets).size > 0 | |
129 | end |
|
129 | end | |
130 | end |
|
130 | end | |
131 |
|
131 | |||
132 | def test_browse_directory |
|
132 | def test_browse_directory | |
133 | assert_equal 0, @repository.changesets.count |
|
133 | assert_equal 0, @repository.changesets.count | |
134 | @repository.fetch_changesets |
|
134 | @repository.fetch_changesets | |
135 | @project.reload |
|
135 | @project.reload | |
136 | assert_equal NUM_REV, @repository.changesets.count |
|
136 | assert_equal NUM_REV, @repository.changesets.count | |
137 | get :show, :id => PRJ_ID, :path => ['images'] |
|
137 | get :show, :id => PRJ_ID, :path => ['images'] | |
138 | assert_response :success |
|
138 | assert_response :success | |
139 | assert_template 'show' |
|
139 | assert_template 'show' | |
140 | assert_not_nil assigns(:entries) |
|
140 | assert_not_nil assigns(:entries) | |
141 | assert_equal ['edit.png'], assigns(:entries).collect(&:name) |
|
141 | assert_equal ['edit.png'], assigns(:entries).collect(&:name) | |
142 | entry = assigns(:entries).detect {|e| e.name == 'edit.png'} |
|
142 | entry = assigns(:entries).detect {|e| e.name == 'edit.png'} | |
143 | assert_not_nil entry |
|
143 | assert_not_nil entry | |
144 | assert_equal 'file', entry.kind |
|
144 | assert_equal 'file', entry.kind | |
145 | assert_equal 'images/edit.png', entry.path |
|
145 | assert_equal 'images/edit.png', entry.path | |
146 | assert_not_nil assigns(:changesets) |
|
146 | assert_not_nil assigns(:changesets) | |
147 | assert assigns(:changesets).size > 0 |
|
147 | assert assigns(:changesets).size > 0 | |
148 | end |
|
148 | end | |
149 |
|
149 | |||
150 | def test_browse_at_given_revision |
|
150 | def test_browse_at_given_revision | |
151 | assert_equal 0, @repository.changesets.count |
|
151 | assert_equal 0, @repository.changesets.count | |
152 | @repository.fetch_changesets |
|
152 | @repository.fetch_changesets | |
153 | @project.reload |
|
153 | @project.reload | |
154 | assert_equal NUM_REV, @repository.changesets.count |
|
154 | assert_equal NUM_REV, @repository.changesets.count | |
155 | get :show, :id => PRJ_ID, :path => ['images'], |
|
155 | get :show, :id => PRJ_ID, :path => ['images'], | |
156 | :rev => '7234cb2750b63f47bff735edc50a1c0a433c2518' |
|
156 | :rev => '7234cb2750b63f47bff735edc50a1c0a433c2518' | |
157 | assert_response :success |
|
157 | assert_response :success | |
158 | assert_template 'show' |
|
158 | assert_template 'show' | |
159 | assert_not_nil assigns(:entries) |
|
159 | assert_not_nil assigns(:entries) | |
160 | assert_equal ['delete.png'], assigns(:entries).collect(&:name) |
|
160 | assert_equal ['delete.png'], assigns(:entries).collect(&:name) | |
161 | assert_not_nil assigns(:changesets) |
|
161 | assert_not_nil assigns(:changesets) | |
162 | assert assigns(:changesets).size > 0 |
|
162 | assert assigns(:changesets).size > 0 | |
163 | end |
|
163 | end | |
164 |
|
164 | |||
165 | def test_changes |
|
165 | def test_changes | |
166 | get :changes, :id => PRJ_ID, :path => ['images', 'edit.png'] |
|
166 | get :changes, :id => PRJ_ID, :path => ['images', 'edit.png'] | |
167 | assert_response :success |
|
167 | assert_response :success | |
168 | assert_template 'changes' |
|
168 | assert_template 'changes' | |
169 | assert_tag :tag => 'h2', :content => 'edit.png' |
|
169 | assert_tag :tag => 'h2', :content => 'edit.png' | |
170 | end |
|
170 | end | |
171 |
|
171 | |||
172 | def test_entry_show |
|
172 | def test_entry_show | |
173 | get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'] |
|
173 | get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'] | |
174 | assert_response :success |
|
174 | assert_response :success | |
175 | assert_template 'entry' |
|
175 | assert_template 'entry' | |
176 | # Line 19 |
|
176 | # Line 19 | |
177 | assert_tag :tag => 'th', |
|
177 | assert_tag :tag => 'th', | |
178 | :content => '11', |
|
178 | :content => '11', | |
179 | :attributes => { :class => 'line-num' }, |
|
179 | :attributes => { :class => 'line-num' }, | |
180 | :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ } |
|
180 | :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ } | |
181 | end |
|
181 | end | |
182 |
|
182 | |||
183 | def test_entry_show_latin_1 |
|
183 | def test_entry_show_latin_1 | |
184 | if @ruby19_non_utf8_pass |
|
184 | if @ruby19_non_utf8_pass | |
185 | puts_ruby19_non_utf8_pass() |
|
185 | puts_ruby19_non_utf8_pass() | |
186 | elsif JRUBY_SKIP |
|
186 | elsif JRUBY_SKIP | |
187 | puts JRUBY_SKIP_STR |
|
187 | puts JRUBY_SKIP_STR | |
188 | else |
|
188 | else | |
189 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do |
|
189 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do | |
190 | ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1| |
|
190 | ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1| | |
191 | get :entry, :id => PRJ_ID, |
|
191 | get :entry, :id => PRJ_ID, | |
192 | :path => ['latin-1-dir', "test-#{@char_1}.txt"], :rev => r1 |
|
192 | :path => ['latin-1-dir', "test-#{@char_1}.txt"], :rev => r1 | |
193 | assert_response :success |
|
193 | assert_response :success | |
194 | assert_template 'entry' |
|
194 | assert_template 'entry' | |
195 | assert_tag :tag => 'th', |
|
195 | assert_tag :tag => 'th', | |
196 | :content => '1', |
|
196 | :content => '1', | |
197 | :attributes => { :class => 'line-num' }, |
|
197 | :attributes => { :class => 'line-num' }, | |
198 | :sibling => { :tag => 'td', |
|
198 | :sibling => { :tag => 'td', | |
199 | :content => /test-#{@char_1}.txt/ } |
|
199 | :content => /test-#{@char_1}.txt/ } | |
200 | end |
|
200 | end | |
201 | end |
|
201 | end | |
202 | end |
|
202 | end | |
203 | end |
|
203 | end | |
204 |
|
204 | |||
205 | def test_entry_download |
|
205 | def test_entry_download | |
206 | get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'], |
|
206 | get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'], | |
207 | :format => 'raw' |
|
207 | :format => 'raw' | |
208 | assert_response :success |
|
208 | assert_response :success | |
209 | # File content |
|
209 | # File content | |
210 | assert @response.body.include?('WITHOUT ANY WARRANTY') |
|
210 | assert @response.body.include?('WITHOUT ANY WARRANTY') | |
211 | end |
|
211 | end | |
212 |
|
212 | |||
213 | def test_directory_entry |
|
213 | def test_directory_entry | |
214 | get :entry, :id => PRJ_ID, :path => ['sources'] |
|
214 | get :entry, :id => PRJ_ID, :path => ['sources'] | |
215 | assert_response :success |
|
215 | assert_response :success | |
216 | assert_template 'show' |
|
216 | assert_template 'show' | |
217 | assert_not_nil assigns(:entry) |
|
217 | assert_not_nil assigns(:entry) | |
218 | assert_equal 'sources', assigns(:entry).name |
|
218 | assert_equal 'sources', assigns(:entry).name | |
219 | end |
|
219 | end | |
220 |
|
220 | |||
221 | def test_diff |
|
221 | def test_diff | |
222 | assert_equal 0, @repository.changesets.count |
|
222 | assert_equal 0, @repository.changesets.count | |
223 | @repository.fetch_changesets |
|
223 | @repository.fetch_changesets | |
224 | @project.reload |
|
224 | @project.reload | |
225 | assert_equal NUM_REV, @repository.changesets.count |
|
225 | assert_equal NUM_REV, @repository.changesets.count | |
226 | # Full diff of changeset 2f9c0091 |
|
226 | # Full diff of changeset 2f9c0091 | |
227 | ['inline', 'sbs'].each do |dt| |
|
227 | ['inline', 'sbs'].each do |dt| | |
228 | get :diff, |
|
228 | get :diff, | |
229 | :id => PRJ_ID, |
|
229 | :id => PRJ_ID, | |
230 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7', |
|
230 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7', | |
231 | :type => dt |
|
231 | :type => dt | |
232 | assert_response :success |
|
232 | assert_response :success | |
233 | assert_template 'diff' |
|
233 | assert_template 'diff' | |
234 | # Line 22 removed |
|
234 | # Line 22 removed | |
235 | assert_tag :tag => 'th', |
|
235 | assert_tag :tag => 'th', | |
236 | :content => /22/, |
|
236 | :content => /22/, | |
237 | :sibling => { :tag => 'td', |
|
237 | :sibling => { :tag => 'td', | |
238 | :attributes => { :class => /diff_out/ }, |
|
238 | :attributes => { :class => /diff_out/ }, | |
239 | :content => /def remove/ } |
|
239 | :content => /def remove/ } | |
240 | assert_tag :tag => 'h2', :content => /2f9c0091/ |
|
240 | assert_tag :tag => 'h2', :content => /2f9c0091/ | |
241 | end |
|
241 | end | |
242 | end |
|
242 | end | |
243 |
|
243 | |||
244 | def test_diff_truncated |
|
244 | def test_diff_truncated | |
245 | assert_equal 0, @repository.changesets.count |
|
245 | assert_equal 0, @repository.changesets.count | |
246 | @repository.fetch_changesets |
|
246 | @repository.fetch_changesets | |
247 | @project.reload |
|
247 | @project.reload | |
248 | assert_equal NUM_REV, @repository.changesets.count |
|
248 | assert_equal NUM_REV, @repository.changesets.count | |
249 | Setting.diff_max_lines_displayed = 5 |
|
249 | Setting.diff_max_lines_displayed = 5 | |
250 |
|
250 | |||
251 | # Truncated diff of changeset 2f9c0091 |
|
251 | # Truncated diff of changeset 2f9c0091 | |
252 | with_cache do |
|
252 | with_cache do | |
253 | get :diff, :id => PRJ_ID, :type => 'inline', |
|
253 | get :diff, :id => PRJ_ID, :type => 'inline', | |
254 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' |
|
254 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' | |
255 | assert_response :success |
|
255 | assert_response :success | |
256 | assert @response.body.include?("... This diff was truncated") |
|
256 | assert @response.body.include?("... This diff was truncated") | |
257 |
|
257 | |||
258 | Setting.default_language = 'fr' |
|
258 | Setting.default_language = 'fr' | |
259 | get :diff, :id => PRJ_ID, :type => 'inline', |
|
259 | get :diff, :id => PRJ_ID, :type => 'inline', | |
260 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' |
|
260 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' | |
261 | assert_response :success |
|
261 | assert_response :success | |
262 | assert ! @response.body.include?("... This diff was truncated") |
|
262 | assert ! @response.body.include?("... This diff was truncated") | |
263 | assert @response.body.include?("... Ce diff") |
|
263 | assert @response.body.include?("... Ce diff") | |
264 | end |
|
264 | end | |
265 | end |
|
265 | end | |
266 |
|
266 | |||
267 | def test_diff_two_revs |
|
267 | def test_diff_two_revs | |
268 | assert_equal 0, @repository.changesets.count |
|
268 | assert_equal 0, @repository.changesets.count | |
269 | @repository.fetch_changesets |
|
269 | @repository.fetch_changesets | |
270 | @project.reload |
|
270 | @project.reload | |
271 | assert_equal NUM_REV, @repository.changesets.count |
|
271 | assert_equal NUM_REV, @repository.changesets.count | |
272 | ['inline', 'sbs'].each do |dt| |
|
272 | ['inline', 'sbs'].each do |dt| | |
273 | get :diff, |
|
273 | get :diff, | |
274 | :id => PRJ_ID, |
|
274 | :id => PRJ_ID, | |
275 | :rev => '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', |
|
275 | :rev => '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', | |
276 | :rev_to => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7', |
|
276 | :rev_to => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7', | |
277 | :type => dt |
|
277 | :type => dt | |
278 | assert_response :success |
|
278 | assert_response :success | |
279 | assert_template 'diff' |
|
279 | assert_template 'diff' | |
280 | diff = assigns(:diff) |
|
280 | diff = assigns(:diff) | |
281 | assert_not_nil diff |
|
281 | assert_not_nil diff | |
282 | assert_tag :tag => 'h2', :content => /2f9c0091:61b685fb/ |
|
282 | assert_tag :tag => 'h2', :content => /2f9c0091:61b685fb/ | |
283 | end |
|
283 | end | |
284 | end |
|
284 | end | |
285 |
|
285 | |||
286 | def test_diff_latin_1 |
|
286 | def test_diff_latin_1 | |
287 | if @ruby19_non_utf8_pass |
|
287 | if @ruby19_non_utf8_pass | |
288 | puts_ruby19_non_utf8_pass() |
|
288 | puts_ruby19_non_utf8_pass() | |
289 | else |
|
289 | else | |
290 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do |
|
290 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do | |
291 | ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1| |
|
291 | ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1| | |
292 | ['inline', 'sbs'].each do |dt| |
|
292 | ['inline', 'sbs'].each do |dt| | |
293 | get :diff, :id => PRJ_ID, :rev => r1, :type => dt |
|
293 | get :diff, :id => PRJ_ID, :rev => r1, :type => dt | |
294 | assert_response :success |
|
294 | assert_response :success | |
295 | assert_template 'diff' |
|
295 | assert_template 'diff' | |
296 | assert_tag :tag => 'thead', |
|
296 | assert_tag :tag => 'thead', | |
297 | :descendant => { |
|
297 | :descendant => { | |
298 | :tag => 'th', |
|
298 | :tag => 'th', | |
299 | :attributes => { :class => 'filename' } , |
|
299 | :attributes => { :class => 'filename' } , | |
300 | :content => /latin-1-dir\/test-#{@char_1}.txt/ , |
|
300 | :content => /latin-1-dir\/test-#{@char_1}.txt/ , | |
301 | }, |
|
301 | }, | |
302 | :sibling => { |
|
302 | :sibling => { | |
303 | :tag => 'tbody', |
|
303 | :tag => 'tbody', | |
304 | :descendant => { |
|
304 | :descendant => { | |
305 | :tag => 'td', |
|
305 | :tag => 'td', | |
306 | :attributes => { :class => /diff_in/ }, |
|
306 | :attributes => { :class => /diff_in/ }, | |
307 | :content => /test-#{@char_1}.txt/ |
|
307 | :content => /test-#{@char_1}.txt/ | |
308 | } |
|
308 | } | |
309 | } |
|
309 | } | |
310 | end |
|
310 | end | |
311 | end |
|
311 | end | |
312 | end |
|
312 | end | |
313 | end |
|
313 | end | |
314 | end |
|
314 | end | |
315 |
|
315 | |||
316 | def test_save_diff_type |
|
316 | def test_save_diff_type | |
317 | @request.session[:user_id] = 1 # admin |
|
317 | @request.session[:user_id] = 1 # admin | |
318 | user = User.find(1) |
|
318 | user = User.find(1) | |
319 | get :diff, |
|
319 | get :diff, | |
320 | :id => PRJ_ID, |
|
320 | :id => PRJ_ID, | |
321 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' |
|
321 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' | |
322 | assert_response :success |
|
322 | assert_response :success | |
323 | assert_template 'diff' |
|
323 | assert_template 'diff' | |
324 | user.reload |
|
324 | user.reload | |
325 | assert_equal "inline", user.pref[:diff_type] |
|
325 | assert_equal "inline", user.pref[:diff_type] | |
326 | get :diff, |
|
326 | get :diff, | |
327 | :id => PRJ_ID, |
|
327 | :id => PRJ_ID, | |
328 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7', |
|
328 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7', | |
329 | :type => 'sbs' |
|
329 | :type => 'sbs' | |
330 | assert_response :success |
|
330 | assert_response :success | |
331 | assert_template 'diff' |
|
331 | assert_template 'diff' | |
332 | user.reload |
|
332 | user.reload | |
333 | assert_equal "sbs", user.pref[:diff_type] |
|
333 | assert_equal "sbs", user.pref[:diff_type] | |
334 | end |
|
334 | end | |
335 |
|
335 | |||
336 | def test_annotate |
|
336 | def test_annotate | |
337 | get :annotate, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'] |
|
337 | get :annotate, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'] | |
338 | assert_response :success |
|
338 | assert_response :success | |
339 | assert_template 'annotate' |
|
339 | assert_template 'annotate' | |
340 | # Line 24, changeset 2f9c0091 |
|
340 | # Line 24, changeset 2f9c0091 | |
341 | assert_tag :tag => 'th', :content => '24', |
|
341 | assert_tag :tag => 'th', :content => '24', | |
342 | :sibling => { |
|
342 | :sibling => { | |
343 | :tag => 'td', |
|
343 | :tag => 'td', | |
344 | :child => { |
|
344 | :child => { | |
345 | :tag => 'a', |
|
345 | :tag => 'a', | |
346 | :content => /2f9c0091/ |
|
346 | :content => /2f9c0091/ | |
347 | } |
|
347 | } | |
348 | } |
|
348 | } | |
349 | assert_tag :tag => 'th', :content => '24', |
|
349 | assert_tag :tag => 'th', :content => '24', | |
350 | :sibling => { :tag => 'td', :content => /jsmith/ } |
|
350 | :sibling => { :tag => 'td', :content => /jsmith/ } | |
351 | assert_tag :tag => 'th', :content => '24', |
|
351 | assert_tag :tag => 'th', :content => '24', | |
352 | :sibling => { |
|
352 | :sibling => { | |
353 | :tag => 'td', |
|
353 | :tag => 'td', | |
354 | :child => { |
|
354 | :child => { | |
355 | :tag => 'a', |
|
355 | :tag => 'a', | |
356 | :content => /2f9c0091/ |
|
356 | :content => /2f9c0091/ | |
357 | } |
|
357 | } | |
358 | } |
|
358 | } | |
359 | assert_tag :tag => 'th', :content => '24', |
|
359 | assert_tag :tag => 'th', :content => '24', | |
360 | :sibling => { :tag => 'td', :content => /watcher =/ } |
|
360 | :sibling => { :tag => 'td', :content => /watcher =/ } | |
361 | end |
|
361 | end | |
362 |
|
362 | |||
363 | def test_annotate_at_given_revision |
|
363 | def test_annotate_at_given_revision | |
364 | assert_equal 0, @repository.changesets.count |
|
364 | assert_equal 0, @repository.changesets.count | |
365 | @repository.fetch_changesets |
|
365 | @repository.fetch_changesets | |
366 | @project.reload |
|
366 | @project.reload | |
367 | assert_equal NUM_REV, @repository.changesets.count |
|
367 | assert_equal NUM_REV, @repository.changesets.count | |
368 | get :annotate, :id => PRJ_ID, :rev => 'deff7', |
|
368 | get :annotate, :id => PRJ_ID, :rev => 'deff7', | |
369 | :path => ['sources', 'watchers_controller.rb'] |
|
369 | :path => ['sources', 'watchers_controller.rb'] | |
370 | assert_response :success |
|
370 | assert_response :success | |
371 | assert_template 'annotate' |
|
371 | assert_template 'annotate' | |
372 | assert_tag :tag => 'h2', :content => /@ deff712f/ |
|
372 | assert_tag :tag => 'h2', :content => /@ deff712f/ | |
373 | end |
|
373 | end | |
374 |
|
374 | |||
375 | def test_annotate_binary_file |
|
375 | def test_annotate_binary_file | |
376 | get :annotate, :id => PRJ_ID, :path => ['images', 'edit.png'] |
|
376 | get :annotate, :id => PRJ_ID, :path => ['images', 'edit.png'] | |
377 | assert_response 500 |
|
377 | assert_response 500 | |
378 | assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, |
|
378 | assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, | |
379 | :content => /cannot be annotated/ |
|
379 | :content => /cannot be annotated/ | |
380 | end |
|
380 | end | |
381 |
|
381 | |||
382 | def test_annotate_error_when_too_big |
|
382 | def test_annotate_error_when_too_big | |
383 | with_settings :file_max_size_displayed => 1 do |
|
383 | with_settings :file_max_size_displayed => 1 do | |
384 | get :annotate, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'], :rev => 'deff712f' |
|
384 | get :annotate, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'], :rev => 'deff712f' | |
385 | assert_response 500 |
|
385 | assert_response 500 | |
386 | assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, |
|
386 | assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, | |
387 | :content => /exceeds the maximum text file size/ |
|
387 | :content => /exceeds the maximum text file size/ | |
388 |
|
388 | |||
389 | get :annotate, :id => PRJ_ID, :path => ['README'], :rev => '7234cb2' |
|
389 | get :annotate, :id => PRJ_ID, :path => ['README'], :rev => '7234cb2' | |
390 | assert_response :success |
|
390 | assert_response :success | |
391 | assert_template 'annotate' |
|
391 | assert_template 'annotate' | |
392 | end |
|
392 | end | |
393 | end |
|
393 | end | |
394 |
|
394 | |||
395 | def test_annotate_latin_1 |
|
395 | def test_annotate_latin_1 | |
396 | if @ruby19_non_utf8_pass |
|
396 | if @ruby19_non_utf8_pass | |
397 | puts_ruby19_non_utf8_pass() |
|
397 | puts_ruby19_non_utf8_pass() | |
398 | elsif JRUBY_SKIP |
|
398 | elsif JRUBY_SKIP | |
399 | puts JRUBY_SKIP_STR |
|
399 | puts JRUBY_SKIP_STR | |
400 | else |
|
400 | else | |
401 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do |
|
401 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do | |
402 | ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1| |
|
402 | ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1| | |
403 | get :annotate, :id => PRJ_ID, |
|
403 | get :annotate, :id => PRJ_ID, | |
404 | :path => ['latin-1-dir', "test-#{@char_1}.txt"], :rev => r1 |
|
404 | :path => ['latin-1-dir', "test-#{@char_1}.txt"], :rev => r1 | |
405 | assert_tag :tag => 'th', |
|
405 | assert_tag :tag => 'th', | |
406 | :content => '1', |
|
406 | :content => '1', | |
407 | :attributes => { :class => 'line-num' }, |
|
407 | :attributes => { :class => 'line-num' }, | |
408 | :sibling => { :tag => 'td', |
|
408 | :sibling => { :tag => 'td', | |
409 | :content => /test-#{@char_1}.txt/ } |
|
409 | :content => /test-#{@char_1}.txt/ } | |
410 | end |
|
410 | end | |
411 | end |
|
411 | end | |
412 | end |
|
412 | end | |
413 | end |
|
413 | end | |
414 |
|
414 | |||
415 | def test_revision |
|
415 | def test_revision | |
416 | assert_equal 0, @repository.changesets.count |
|
416 | assert_equal 0, @repository.changesets.count | |
417 | @repository.fetch_changesets |
|
417 | @repository.fetch_changesets | |
418 | @project.reload |
|
418 | @project.reload | |
419 | assert_equal NUM_REV, @repository.changesets.count |
|
419 | assert_equal NUM_REV, @repository.changesets.count | |
420 | ['61b685fbe55ab05b5ac68402d5720c1a6ac973d1', '61b685f'].each do |r| |
|
420 | ['61b685fbe55ab05b5ac68402d5720c1a6ac973d1', '61b685f'].each do |r| | |
421 | get :revision, :id => PRJ_ID, :rev => r |
|
421 | get :revision, :id => PRJ_ID, :rev => r | |
422 | assert_response :success |
|
422 | assert_response :success | |
423 | assert_template 'revision' |
|
423 | assert_template 'revision' | |
424 | end |
|
424 | end | |
425 | end |
|
425 | end | |
426 |
|
426 | |||
427 | def test_empty_revision |
|
427 | def test_empty_revision | |
428 | assert_equal 0, @repository.changesets.count |
|
428 | assert_equal 0, @repository.changesets.count | |
429 | @repository.fetch_changesets |
|
429 | @repository.fetch_changesets | |
430 | @project.reload |
|
430 | @project.reload | |
431 | assert_equal NUM_REV, @repository.changesets.count |
|
431 | assert_equal NUM_REV, @repository.changesets.count | |
432 | ['', ' ', nil].each do |r| |
|
432 | ['', ' ', nil].each do |r| | |
433 | get :revision, :id => PRJ_ID, :rev => r |
|
433 | get :revision, :id => PRJ_ID, :rev => r | |
434 | assert_response 404 |
|
434 | assert_response 404 | |
435 | assert_error_tag :content => /was not found/ |
|
435 | assert_error_tag :content => /was not found/ | |
436 | end |
|
436 | end | |
437 | end |
|
437 | end | |
438 |
|
438 | |||
439 | def test_destroy_valid_repository |
|
439 | def test_destroy_valid_repository | |
440 | @request.session[:user_id] = 1 # admin |
|
440 | @request.session[:user_id] = 1 # admin | |
441 | assert_equal 0, @repository.changesets.count |
|
441 | assert_equal 0, @repository.changesets.count | |
442 | @repository.fetch_changesets |
|
442 | @repository.fetch_changesets | |
443 | @project.reload |
|
443 | @project.reload | |
444 | assert_equal NUM_REV, @repository.changesets.count |
|
444 | assert_equal NUM_REV, @repository.changesets.count | |
445 |
|
445 | |||
446 | assert_difference 'Repository.count', -1 do |
|
446 | assert_difference 'Repository.count', -1 do | |
447 | delete :destroy, :id => @repository.id |
|
447 | delete :destroy, :id => @repository.id | |
448 | end |
|
448 | end | |
449 | assert_response 302 |
|
449 | assert_response 302 | |
450 | @project.reload |
|
450 | @project.reload | |
451 | assert_nil @project.repository |
|
451 | assert_nil @project.repository | |
452 | end |
|
452 | end | |
453 |
|
453 | |||
454 | def test_destroy_invalid_repository |
|
454 | def test_destroy_invalid_repository | |
455 | @request.session[:user_id] = 1 # admin |
|
455 | @request.session[:user_id] = 1 # admin | |
456 | @project.repository.destroy |
|
456 | @project.repository.destroy | |
457 | @repository = Repository::Git.create!( |
|
457 | @repository = Repository::Git.create!( | |
458 | :project => @project, |
|
458 | :project => @project, | |
459 | :url => "/invalid", |
|
459 | :url => "/invalid", | |
460 | :path_encoding => 'ISO-8859-1' |
|
460 | :path_encoding => 'ISO-8859-1' | |
461 | ) |
|
461 | ) | |
462 | @repository.fetch_changesets |
|
462 | @repository.fetch_changesets | |
463 | @repository.reload |
|
463 | @repository.reload | |
464 | assert_equal 0, @repository.changesets.count |
|
464 | assert_equal 0, @repository.changesets.count | |
465 |
|
465 | |||
466 | assert_difference 'Repository.count', -1 do |
|
466 | assert_difference 'Repository.count', -1 do | |
467 | delete :destroy, :id => @repository.id |
|
467 | delete :destroy, :id => @repository.id | |
468 | end |
|
468 | end | |
469 | assert_response 302 |
|
469 | assert_response 302 | |
470 | @project.reload |
|
470 | @project.reload | |
471 | assert_nil @project.repository |
|
471 | assert_nil @project.repository | |
472 | end |
|
472 | end | |
473 |
|
473 | |||
474 | private |
|
474 | private | |
475 |
|
475 | |||
476 | def puts_ruby19_non_utf8_pass |
|
476 | def puts_ruby19_non_utf8_pass | |
477 | puts "TODO: This test fails in Ruby 1.9 " + |
|
477 | puts "TODO: This test fails in Ruby 1.9 " + | |
478 | "and Encoding.default_external is not UTF-8. " + |
|
478 | "and Encoding.default_external is not UTF-8. " + | |
479 | "Current value is '#{Encoding.default_external.to_s}'" |
|
479 | "Current value is '#{Encoding.default_external.to_s}'" | |
480 | end |
|
480 | end | |
481 | else |
|
481 | else | |
482 | puts "Git test repository NOT FOUND. Skipping functional tests !!!" |
|
482 | puts "Git test repository NOT FOUND. Skipping functional tests !!!" | |
483 | def test_fake; assert true end |
|
483 | def test_fake; assert true end | |
484 | end |
|
484 | end | |
485 |
|
485 | |||
486 | private |
|
486 | private | |
487 | def with_cache(&block) |
|
487 | def with_cache(&block) | |
488 | before = ActionController::Base.perform_caching |
|
488 | before = ActionController::Base.perform_caching | |
489 | ActionController::Base.perform_caching = true |
|
489 | ActionController::Base.perform_caching = true | |
490 | block.call |
|
490 | block.call | |
491 | ActionController::Base.perform_caching = before |
|
491 | ActionController::Base.perform_caching = before | |
492 | end |
|
492 | end | |
493 | end |
|
493 | end |
@@ -1,494 +1,498 | |||||
1 | # encoding: utf-8 |
|
1 | # encoding: utf-8 | |
2 |
|
2 | |||
3 | # This file includes UTF-8 "Felix Schäfer". |
|
3 | # This file includes UTF-8 "Felix Schäfer". | |
4 | # We need to consider Ruby 1.9 compatibility. |
|
4 | # We need to consider Ruby 1.9 compatibility. | |
5 |
|
5 | |||
6 | require File.expand_path('../../../../../../test_helper', __FILE__) |
|
6 | require File.expand_path('../../../../../../test_helper', __FILE__) | |
7 | begin |
|
7 | begin | |
8 | require 'mocha' |
|
8 | require 'mocha' | |
9 |
|
9 | |||
10 | class GitAdapterTest < ActiveSupport::TestCase |
|
10 | class GitAdapterTest < ActiveSupport::TestCase | |
11 | REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s |
|
11 | REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s | |
12 |
|
12 | |||
13 | FELIX_UTF8 = "Felix Schäfer" |
|
13 | FELIX_UTF8 = "Felix Schäfer" | |
14 | FELIX_HEX = "Felix Sch\xC3\xA4fer" |
|
14 | FELIX_HEX = "Felix Sch\xC3\xA4fer" | |
15 | CHAR_1_HEX = "\xc3\x9c" |
|
15 | CHAR_1_HEX = "\xc3\x9c" | |
16 |
|
16 | |||
17 | ## Ruby uses ANSI api to fork a process on Windows. |
|
17 | ## Ruby uses ANSI api to fork a process on Windows. | |
18 | ## Japanese Shift_JIS and Traditional Chinese Big5 have 0x5c(backslash) problem |
|
18 | ## Japanese Shift_JIS and Traditional Chinese Big5 have 0x5c(backslash) problem | |
19 | ## and these are incompatible with ASCII. |
|
19 | ## and these are incompatible with ASCII. | |
20 | # WINDOWS_PASS = Redmine::Platform.mswin? |
|
20 | # WINDOWS_PASS = Redmine::Platform.mswin? | |
21 | WINDOWS_PASS = false |
|
21 | WINDOWS_PASS = false | |
22 |
|
22 | |||
23 | ## Git, Mercurial and CVS path encodings are binary. |
|
23 | ## Git, Mercurial and CVS path encodings are binary. | |
24 | ## Subversion supports URL encoding for path. |
|
24 | ## Subversion supports URL encoding for path. | |
25 | ## Redmine Mercurial adapter and extension use URL encoding. |
|
25 | ## Redmine Mercurial adapter and extension use URL encoding. | |
26 | ## Git accepts only binary path in command line parameter. |
|
26 | ## Git accepts only binary path in command line parameter. | |
27 | ## So, there is no way to use binary command line parameter in JRuby. |
|
27 | ## So, there is no way to use binary command line parameter in JRuby. | |
28 | JRUBY_SKIP = (RUBY_PLATFORM == 'java') |
|
28 | JRUBY_SKIP = (RUBY_PLATFORM == 'java') | |
29 | JRUBY_SKIP_STR = "TODO: This test fails in JRuby" |
|
29 | JRUBY_SKIP_STR = "TODO: This test fails in JRuby" | |
30 |
|
30 | |||
31 | if File.directory?(REPOSITORY_PATH) |
|
31 | if File.directory?(REPOSITORY_PATH) | |
32 | def setup |
|
32 | def setup | |
33 | adapter_class = Redmine::Scm::Adapters::GitAdapter |
|
33 | adapter_class = Redmine::Scm::Adapters::GitAdapter | |
34 | assert adapter_class |
|
34 | assert adapter_class | |
35 | assert adapter_class.client_command |
|
35 | assert adapter_class.client_command | |
36 | assert_equal true, adapter_class.client_available |
|
36 | assert_equal true, adapter_class.client_available | |
37 | assert_equal true, adapter_class.client_version_above?([1]) |
|
37 | assert_equal true, adapter_class.client_version_above?([1]) | |
38 | assert_equal true, adapter_class.client_version_above?([1, 0]) |
|
38 | assert_equal true, adapter_class.client_version_above?([1, 0]) | |
39 |
|
39 | |||
40 | @adapter = Redmine::Scm::Adapters::GitAdapter.new( |
|
40 | @adapter = Redmine::Scm::Adapters::GitAdapter.new( | |
41 | REPOSITORY_PATH, |
|
41 | REPOSITORY_PATH, | |
42 | nil, |
|
42 | nil, | |
43 | nil, |
|
43 | nil, | |
44 | nil, |
|
44 | nil, | |
45 | 'ISO-8859-1' |
|
45 | 'ISO-8859-1' | |
46 | ) |
|
46 | ) | |
47 | assert @adapter |
|
47 | assert @adapter | |
48 | @char_1 = CHAR_1_HEX.dup |
|
48 | @char_1 = CHAR_1_HEX.dup | |
49 | if @char_1.respond_to?(:force_encoding) |
|
49 | if @char_1.respond_to?(:force_encoding) | |
50 | @char_1.force_encoding('UTF-8') |
|
50 | @char_1.force_encoding('UTF-8') | |
51 | end |
|
51 | end | |
52 | end |
|
52 | end | |
53 |
|
53 | |||
54 | def test_scm_version |
|
54 | def test_scm_version | |
55 | to_test = { "git version 1.7.3.4\n" => [1,7,3,4], |
|
55 | to_test = { "git version 1.7.3.4\n" => [1,7,3,4], | |
56 | "1.6.1\n1.7\n1.8" => [1,6,1], |
|
56 | "1.6.1\n1.7\n1.8" => [1,6,1], | |
57 | "1.6.2\r\n1.8.1\r\n1.9.1" => [1,6,2]} |
|
57 | "1.6.2\r\n1.8.1\r\n1.9.1" => [1,6,2]} | |
58 | to_test.each do |s, v| |
|
58 | to_test.each do |s, v| | |
59 | test_scm_version_for(s, v) |
|
59 | test_scm_version_for(s, v) | |
60 | end |
|
60 | end | |
61 | end |
|
61 | end | |
62 |
|
62 | |||
63 | def test_branches |
|
63 | def test_branches | |
64 | brs = [] |
|
64 | brs = [] | |
65 | @adapter.branches.each do |b| |
|
65 | @adapter.branches.each do |b| | |
66 | brs << b |
|
66 | brs << b | |
67 | end |
|
67 | end | |
68 |
assert_equal |
|
68 | assert_equal 5, brs.length | |
|
69 | br_issue_8857 = brs[-5] | |||
|
70 | assert_equal 'issue-8857', br_issue_8857.to_s | |||
|
71 | assert_equal '2a682156a3b6e77a8bf9cd4590e8db757f3c6c78', br_issue_8857.revision | |||
|
72 | assert_equal br_issue_8857.scmid, br_issue_8857.revision | |||
69 | br_latin_1_path = brs[-4] |
|
73 | br_latin_1_path = brs[-4] | |
70 | assert_equal 'latin-1-path-encoding', br_latin_1_path.to_s |
|
74 | assert_equal 'latin-1-path-encoding', br_latin_1_path.to_s | |
71 | assert_equal '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127', br_latin_1_path.revision |
|
75 | assert_equal '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127', br_latin_1_path.revision | |
72 | assert_equal br_latin_1_path.scmid, br_latin_1_path.revision |
|
76 | assert_equal br_latin_1_path.scmid, br_latin_1_path.revision | |
73 | br_master = brs[-3] |
|
77 | br_master = brs[-3] | |
74 | assert_equal 'master', br_master.to_s |
|
78 | assert_equal 'master', br_master.to_s | |
75 | assert_equal '83ca5fd546063a3c7dc2e568ba3355661a9e2b2c', br_master.revision |
|
79 | assert_equal '83ca5fd546063a3c7dc2e568ba3355661a9e2b2c', br_master.revision | |
76 | assert_equal br_master.scmid, br_master.revision |
|
80 | assert_equal br_master.scmid, br_master.revision | |
77 | br_latin_1 = brs[-2] |
|
81 | br_latin_1 = brs[-2] | |
78 | assert_equal 'test-latin-1', br_latin_1.to_s |
|
82 | assert_equal 'test-latin-1', br_latin_1.to_s | |
79 | assert_equal '67e7792ce20ccae2e4bb73eed09bb397819c8834', br_latin_1.revision |
|
83 | assert_equal '67e7792ce20ccae2e4bb73eed09bb397819c8834', br_latin_1.revision | |
80 | assert_equal br_latin_1.scmid, br_latin_1.revision |
|
84 | assert_equal br_latin_1.scmid, br_latin_1.revision | |
81 | br_test = brs[-1] |
|
85 | br_test = brs[-1] | |
82 | assert_equal 'test_branch', br_test.to_s |
|
86 | assert_equal 'test_branch', br_test.to_s | |
83 | assert_equal 'fba357b886984ee71185ad2065e65fc0417d9b92', br_test.revision |
|
87 | assert_equal 'fba357b886984ee71185ad2065e65fc0417d9b92', br_test.revision | |
84 | assert_equal br_test.scmid, br_test.revision |
|
88 | assert_equal br_test.scmid, br_test.revision | |
85 | end |
|
89 | end | |
86 |
|
90 | |||
87 | def test_tags |
|
91 | def test_tags | |
88 | assert_equal [ |
|
92 | assert_equal [ | |
89 | "tag00.lightweight", |
|
93 | "tag00.lightweight", | |
90 | "tag01.annotated", |
|
94 | "tag01.annotated", | |
91 | ], @adapter.tags |
|
95 | ], @adapter.tags | |
92 | end |
|
96 | end | |
93 |
|
97 | |||
94 | def test_revisions_master_all |
|
98 | def test_revisions_master_all | |
95 | revs1 = [] |
|
99 | revs1 = [] | |
96 | @adapter.revisions('', nil, "master",{}) do |rev| |
|
100 | @adapter.revisions('', nil, "master",{}) do |rev| | |
97 | revs1 << rev |
|
101 | revs1 << rev | |
98 | end |
|
102 | end | |
99 | assert_equal 15, revs1.length |
|
103 | assert_equal 15, revs1.length | |
100 | assert_equal '83ca5fd546063a3c7dc2e568ba3355661a9e2b2c', revs1[ 0].identifier |
|
104 | assert_equal '83ca5fd546063a3c7dc2e568ba3355661a9e2b2c', revs1[ 0].identifier | |
101 | assert_equal '7234cb2750b63f47bff735edc50a1c0a433c2518', revs1[-1].identifier |
|
105 | assert_equal '7234cb2750b63f47bff735edc50a1c0a433c2518', revs1[-1].identifier | |
102 |
|
106 | |||
103 | revs2 = [] |
|
107 | revs2 = [] | |
104 | @adapter.revisions('', nil, "master", |
|
108 | @adapter.revisions('', nil, "master", | |
105 | {:reverse => true}) do |rev| |
|
109 | {:reverse => true}) do |rev| | |
106 | revs2 << rev |
|
110 | revs2 << rev | |
107 | end |
|
111 | end | |
108 | assert_equal 15, revs2.length |
|
112 | assert_equal 15, revs2.length | |
109 | assert_equal '83ca5fd546063a3c7dc2e568ba3355661a9e2b2c', revs2[-1].identifier |
|
113 | assert_equal '83ca5fd546063a3c7dc2e568ba3355661a9e2b2c', revs2[-1].identifier | |
110 | assert_equal '7234cb2750b63f47bff735edc50a1c0a433c2518', revs2[ 0].identifier |
|
114 | assert_equal '7234cb2750b63f47bff735edc50a1c0a433c2518', revs2[ 0].identifier | |
111 | end |
|
115 | end | |
112 |
|
116 | |||
113 | def test_revisions_master_merged_rev |
|
117 | def test_revisions_master_merged_rev | |
114 | revs1 = [] |
|
118 | revs1 = [] | |
115 | @adapter.revisions('', |
|
119 | @adapter.revisions('', | |
116 | "713f4944648826f558cf548222f813dabe7cbb04", |
|
120 | "713f4944648826f558cf548222f813dabe7cbb04", | |
117 | "master", |
|
121 | "master", | |
118 | {:reverse => true}) do |rev| |
|
122 | {:reverse => true}) do |rev| | |
119 | revs1 << rev |
|
123 | revs1 << rev | |
120 | end |
|
124 | end | |
121 | assert_equal 8, revs1.length |
|
125 | assert_equal 8, revs1.length | |
122 | assert_equal 'fba357b886984ee71185ad2065e65fc0417d9b92', revs1[ 0].identifier |
|
126 | assert_equal 'fba357b886984ee71185ad2065e65fc0417d9b92', revs1[ 0].identifier | |
123 | assert_equal '7e61ac704deecde634b51e59daa8110435dcb3da', revs1[ 1].identifier |
|
127 | assert_equal '7e61ac704deecde634b51e59daa8110435dcb3da', revs1[ 1].identifier | |
124 | # 4a07fe31b is not a child of 713f49446 |
|
128 | # 4a07fe31b is not a child of 713f49446 | |
125 | assert_equal '4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8', revs1[ 2].identifier |
|
129 | assert_equal '4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8', revs1[ 2].identifier | |
126 | # Merged revision |
|
130 | # Merged revision | |
127 | assert_equal '32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf', revs1[ 3].identifier |
|
131 | assert_equal '32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf', revs1[ 3].identifier | |
128 | assert_equal '83ca5fd546063a3c7dc2e568ba3355661a9e2b2c', revs1[-1].identifier |
|
132 | assert_equal '83ca5fd546063a3c7dc2e568ba3355661a9e2b2c', revs1[-1].identifier | |
129 |
|
133 | |||
130 | revs2 = [] |
|
134 | revs2 = [] | |
131 | @adapter.revisions('', |
|
135 | @adapter.revisions('', | |
132 | "fba357b886984ee71185ad2065e65fc0417d9b92", |
|
136 | "fba357b886984ee71185ad2065e65fc0417d9b92", | |
133 | "master", |
|
137 | "master", | |
134 | {:reverse => true}) do |rev| |
|
138 | {:reverse => true}) do |rev| | |
135 | revs2 << rev |
|
139 | revs2 << rev | |
136 | end |
|
140 | end | |
137 | assert_equal 7, revs2.length |
|
141 | assert_equal 7, revs2.length | |
138 | assert_equal '7e61ac704deecde634b51e59daa8110435dcb3da', revs2[ 0].identifier |
|
142 | assert_equal '7e61ac704deecde634b51e59daa8110435dcb3da', revs2[ 0].identifier | |
139 | # 4a07fe31b is not a child of fba357b8869 |
|
143 | # 4a07fe31b is not a child of fba357b8869 | |
140 | assert_equal '4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8', revs2[ 1].identifier |
|
144 | assert_equal '4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8', revs2[ 1].identifier | |
141 | # Merged revision |
|
145 | # Merged revision | |
142 | assert_equal '32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf', revs2[ 2].identifier |
|
146 | assert_equal '32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf', revs2[ 2].identifier | |
143 | assert_equal '83ca5fd546063a3c7dc2e568ba3355661a9e2b2c', revs2[-1].identifier |
|
147 | assert_equal '83ca5fd546063a3c7dc2e568ba3355661a9e2b2c', revs2[-1].identifier | |
144 | end |
|
148 | end | |
145 |
|
149 | |||
146 | def test_revisions_branch_latin_1_path_encoding_all |
|
150 | def test_revisions_branch_latin_1_path_encoding_all | |
147 | revs1 = [] |
|
151 | revs1 = [] | |
148 | @adapter.revisions('', nil, "latin-1-path-encoding",{}) do |rev| |
|
152 | @adapter.revisions('', nil, "latin-1-path-encoding",{}) do |rev| | |
149 | revs1 << rev |
|
153 | revs1 << rev | |
150 | end |
|
154 | end | |
151 | assert_equal 8, revs1.length |
|
155 | assert_equal 8, revs1.length | |
152 | assert_equal '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127', revs1[ 0].identifier |
|
156 | assert_equal '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127', revs1[ 0].identifier | |
153 | assert_equal '7234cb2750b63f47bff735edc50a1c0a433c2518', revs1[-1].identifier |
|
157 | assert_equal '7234cb2750b63f47bff735edc50a1c0a433c2518', revs1[-1].identifier | |
154 |
|
158 | |||
155 | revs2 = [] |
|
159 | revs2 = [] | |
156 | @adapter.revisions('', nil, "latin-1-path-encoding", |
|
160 | @adapter.revisions('', nil, "latin-1-path-encoding", | |
157 | {:reverse => true}) do |rev| |
|
161 | {:reverse => true}) do |rev| | |
158 | revs2 << rev |
|
162 | revs2 << rev | |
159 | end |
|
163 | end | |
160 | assert_equal 8, revs2.length |
|
164 | assert_equal 8, revs2.length | |
161 | assert_equal '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127', revs2[-1].identifier |
|
165 | assert_equal '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127', revs2[-1].identifier | |
162 | assert_equal '7234cb2750b63f47bff735edc50a1c0a433c2518', revs2[ 0].identifier |
|
166 | assert_equal '7234cb2750b63f47bff735edc50a1c0a433c2518', revs2[ 0].identifier | |
163 | end |
|
167 | end | |
164 |
|
168 | |||
165 | def test_revisions_branch_latin_1_path_encoding_with_rev |
|
169 | def test_revisions_branch_latin_1_path_encoding_with_rev | |
166 | revs1 = [] |
|
170 | revs1 = [] | |
167 | @adapter.revisions('', |
|
171 | @adapter.revisions('', | |
168 | '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
172 | '7234cb2750b63f47bff735edc50a1c0a433c2518', | |
169 | "latin-1-path-encoding", |
|
173 | "latin-1-path-encoding", | |
170 | {:reverse => true}) do |rev| |
|
174 | {:reverse => true}) do |rev| | |
171 | revs1 << rev |
|
175 | revs1 << rev | |
172 | end |
|
176 | end | |
173 | assert_equal 7, revs1.length |
|
177 | assert_equal 7, revs1.length | |
174 | assert_equal '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', revs1[ 0].identifier |
|
178 | assert_equal '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', revs1[ 0].identifier | |
175 | assert_equal '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127', revs1[-1].identifier |
|
179 | assert_equal '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127', revs1[-1].identifier | |
176 |
|
180 | |||
177 | revs2 = [] |
|
181 | revs2 = [] | |
178 | @adapter.revisions('', |
|
182 | @adapter.revisions('', | |
179 | '57ca437c0acbbcb749821fdf3726a1367056d364', |
|
183 | '57ca437c0acbbcb749821fdf3726a1367056d364', | |
180 | "latin-1-path-encoding", |
|
184 | "latin-1-path-encoding", | |
181 | {:reverse => true}) do |rev| |
|
185 | {:reverse => true}) do |rev| | |
182 | revs2 << rev |
|
186 | revs2 << rev | |
183 | end |
|
187 | end | |
184 | assert_equal 3, revs2.length |
|
188 | assert_equal 3, revs2.length | |
185 | assert_equal '4fc55c43bf3d3dc2efb66145365ddc17639ce81e', revs2[ 0].identifier |
|
189 | assert_equal '4fc55c43bf3d3dc2efb66145365ddc17639ce81e', revs2[ 0].identifier | |
186 | assert_equal '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127', revs2[-1].identifier |
|
190 | assert_equal '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127', revs2[-1].identifier | |
187 | end |
|
191 | end | |
188 |
|
192 | |||
189 | def test_revisions_invalid_rev |
|
193 | def test_revisions_invalid_rev | |
190 | revs1 = [] |
|
194 | revs1 = [] | |
191 | @adapter.revisions('', |
|
195 | @adapter.revisions('', | |
192 | '1234abcd', |
|
196 | '1234abcd', | |
193 | "master", |
|
197 | "master", | |
194 | {:reverse => true}) do |rev| |
|
198 | {:reverse => true}) do |rev| | |
195 | revs1 << rev |
|
199 | revs1 << rev | |
196 | end |
|
200 | end | |
197 | assert_equal [], revs1 |
|
201 | assert_equal [], revs1 | |
198 | end |
|
202 | end | |
199 |
|
203 | |||
200 | def test_revisions_includes_master_two_revs |
|
204 | def test_revisions_includes_master_two_revs | |
201 | revs1 = [] |
|
205 | revs1 = [] | |
202 | @adapter.revisions('', nil, nil, |
|
206 | @adapter.revisions('', nil, nil, | |
203 | {:reverse => true, |
|
207 | {:reverse => true, | |
204 | :includes => ['83ca5fd546063a3c7dc2e568ba3355661a9e2b2c'], |
|
208 | :includes => ['83ca5fd546063a3c7dc2e568ba3355661a9e2b2c'], | |
205 | :excludes => ['4f26664364207fa8b1af9f8722647ab2d4ac5d43']}) do |rev| |
|
209 | :excludes => ['4f26664364207fa8b1af9f8722647ab2d4ac5d43']}) do |rev| | |
206 | revs1 << rev |
|
210 | revs1 << rev | |
207 | end |
|
211 | end | |
208 | assert_equal 2, revs1.length |
|
212 | assert_equal 2, revs1.length | |
209 | assert_equal 'ed5bb786bbda2dee66a2d50faf51429dbc043a7b', revs1[ 0].identifier |
|
213 | assert_equal 'ed5bb786bbda2dee66a2d50faf51429dbc043a7b', revs1[ 0].identifier | |
210 | assert_equal '83ca5fd546063a3c7dc2e568ba3355661a9e2b2c', revs1[-1].identifier |
|
214 | assert_equal '83ca5fd546063a3c7dc2e568ba3355661a9e2b2c', revs1[-1].identifier | |
211 | end |
|
215 | end | |
212 |
|
216 | |||
213 | def test_revisions_includes_master_two_revs_from_origin |
|
217 | def test_revisions_includes_master_two_revs_from_origin | |
214 | revs1 = [] |
|
218 | revs1 = [] | |
215 | @adapter.revisions('', nil, nil, |
|
219 | @adapter.revisions('', nil, nil, | |
216 | {:reverse => true, |
|
220 | {:reverse => true, | |
217 | :includes => ['899a15dba03a3b350b89c3f537e4bbe02a03cdc9']}) do |rev| |
|
221 | :includes => ['899a15dba03a3b350b89c3f537e4bbe02a03cdc9']}) do |rev| | |
218 | revs1 << rev |
|
222 | revs1 << rev | |
219 | end |
|
223 | end | |
220 | assert_equal 2, revs1.length |
|
224 | assert_equal 2, revs1.length | |
221 | assert_equal '7234cb2750b63f47bff735edc50a1c0a433c2518', revs1[ 0].identifier |
|
225 | assert_equal '7234cb2750b63f47bff735edc50a1c0a433c2518', revs1[ 0].identifier | |
222 | assert_equal '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', revs1[ 1].identifier |
|
226 | assert_equal '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', revs1[ 1].identifier | |
223 | end |
|
227 | end | |
224 |
|
228 | |||
225 | def test_revisions_includes_merged_revs |
|
229 | def test_revisions_includes_merged_revs | |
226 | revs1 = [] |
|
230 | revs1 = [] | |
227 | @adapter.revisions('', nil, nil, |
|
231 | @adapter.revisions('', nil, nil, | |
228 | {:reverse => true, |
|
232 | {:reverse => true, | |
229 | :includes => ['83ca5fd546063a3c7dc2e568ba3355661a9e2b2c'], |
|
233 | :includes => ['83ca5fd546063a3c7dc2e568ba3355661a9e2b2c'], | |
230 | :excludes => ['fba357b886984ee71185ad2065e65fc0417d9b92']}) do |rev| |
|
234 | :excludes => ['fba357b886984ee71185ad2065e65fc0417d9b92']}) do |rev| | |
231 | revs1 << rev |
|
235 | revs1 << rev | |
232 | end |
|
236 | end | |
233 | assert_equal 7, revs1.length |
|
237 | assert_equal 7, revs1.length | |
234 | assert_equal '7e61ac704deecde634b51e59daa8110435dcb3da', revs1[ 0].identifier |
|
238 | assert_equal '7e61ac704deecde634b51e59daa8110435dcb3da', revs1[ 0].identifier | |
235 | assert_equal '4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8', revs1[ 1].identifier |
|
239 | assert_equal '4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8', revs1[ 1].identifier | |
236 | assert_equal '32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf', revs1[ 2].identifier |
|
240 | assert_equal '32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf', revs1[ 2].identifier | |
237 | assert_equal '83ca5fd546063a3c7dc2e568ba3355661a9e2b2c', revs1[-1].identifier |
|
241 | assert_equal '83ca5fd546063a3c7dc2e568ba3355661a9e2b2c', revs1[-1].identifier | |
238 | end |
|
242 | end | |
239 |
|
243 | |||
240 | def test_revisions_includes_two_heads |
|
244 | def test_revisions_includes_two_heads | |
241 | revs1 = [] |
|
245 | revs1 = [] | |
242 | @adapter.revisions('', nil, nil, |
|
246 | @adapter.revisions('', nil, nil, | |
243 | {:reverse => true, |
|
247 | {:reverse => true, | |
244 | :includes => ['83ca5fd546063a3c7dc2e568ba3355661a9e2b2c', |
|
248 | :includes => ['83ca5fd546063a3c7dc2e568ba3355661a9e2b2c', | |
245 | '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127'], |
|
249 | '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127'], | |
246 | :excludes => ['4f26664364207fa8b1af9f8722647ab2d4ac5d43', |
|
250 | :excludes => ['4f26664364207fa8b1af9f8722647ab2d4ac5d43', | |
247 | '4fc55c43bf3d3dc2efb66145365ddc17639ce81e']}) do |rev| |
|
251 | '4fc55c43bf3d3dc2efb66145365ddc17639ce81e']}) do |rev| | |
248 | revs1 << rev |
|
252 | revs1 << rev | |
249 | end |
|
253 | end | |
250 | assert_equal 4, revs1.length |
|
254 | assert_equal 4, revs1.length | |
251 | assert_equal 'ed5bb786bbda2dee66a2d50faf51429dbc043a7b', revs1[ 0].identifier |
|
255 | assert_equal 'ed5bb786bbda2dee66a2d50faf51429dbc043a7b', revs1[ 0].identifier | |
252 | assert_equal '83ca5fd546063a3c7dc2e568ba3355661a9e2b2c', revs1[ 1].identifier |
|
256 | assert_equal '83ca5fd546063a3c7dc2e568ba3355661a9e2b2c', revs1[ 1].identifier | |
253 | assert_equal '64f1f3e89ad1cb57976ff0ad99a107012ba3481d', revs1[-2].identifier |
|
257 | assert_equal '64f1f3e89ad1cb57976ff0ad99a107012ba3481d', revs1[-2].identifier | |
254 | assert_equal '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127', revs1[-1].identifier |
|
258 | assert_equal '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127', revs1[-1].identifier | |
255 | end |
|
259 | end | |
256 |
|
260 | |||
257 | def test_revisions_invalid_rev_excludes |
|
261 | def test_revisions_invalid_rev_excludes | |
258 | revs1 = [] |
|
262 | revs1 = [] | |
259 | @adapter.revisions('', nil, nil, |
|
263 | @adapter.revisions('', nil, nil, | |
260 | {:reverse => true, |
|
264 | {:reverse => true, | |
261 | :includes => ['83ca5fd546063a3c7dc2e568ba3355661a9e2b2c'], |
|
265 | :includes => ['83ca5fd546063a3c7dc2e568ba3355661a9e2b2c'], | |
262 | :excludes => ['0123abcd4567']}) do |rev| |
|
266 | :excludes => ['0123abcd4567']}) do |rev| | |
263 | revs1 << rev |
|
267 | revs1 << rev | |
264 | end |
|
268 | end | |
265 | assert_equal [], revs1 |
|
269 | assert_equal [], revs1 | |
266 | end |
|
270 | end | |
267 |
|
271 | |||
268 | def test_getting_revisions_with_spaces_in_filename |
|
272 | def test_getting_revisions_with_spaces_in_filename | |
269 | assert_equal 1, @adapter.revisions("filemane with spaces.txt", |
|
273 | assert_equal 1, @adapter.revisions("filemane with spaces.txt", | |
270 | nil, "master").length |
|
274 | nil, "master").length | |
271 | end |
|
275 | end | |
272 |
|
276 | |||
273 | def test_parents |
|
277 | def test_parents | |
274 | revs1 = [] |
|
278 | revs1 = [] | |
275 | @adapter.revisions('', |
|
279 | @adapter.revisions('', | |
276 | nil, |
|
280 | nil, | |
277 | "master", |
|
281 | "master", | |
278 | {:reverse => true}) do |rev| |
|
282 | {:reverse => true}) do |rev| | |
279 | revs1 << rev |
|
283 | revs1 << rev | |
280 | end |
|
284 | end | |
281 | assert_equal 15, revs1.length |
|
285 | assert_equal 15, revs1.length | |
282 | assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", |
|
286 | assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", | |
283 | revs1[0].identifier |
|
287 | revs1[0].identifier | |
284 | assert_equal nil, revs1[0].parents |
|
288 | assert_equal nil, revs1[0].parents | |
285 | assert_equal "899a15dba03a3b350b89c3f537e4bbe02a03cdc9", |
|
289 | assert_equal "899a15dba03a3b350b89c3f537e4bbe02a03cdc9", | |
286 | revs1[1].identifier |
|
290 | revs1[1].identifier | |
287 | assert_equal 1, revs1[1].parents.length |
|
291 | assert_equal 1, revs1[1].parents.length | |
288 | assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", |
|
292 | assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", | |
289 | revs1[1].parents[0] |
|
293 | revs1[1].parents[0] | |
290 | assert_equal "32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf", |
|
294 | assert_equal "32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf", | |
291 | revs1[10].identifier |
|
295 | revs1[10].identifier | |
292 | assert_equal 2, revs1[10].parents.length |
|
296 | assert_equal 2, revs1[10].parents.length | |
293 | assert_equal "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8", |
|
297 | assert_equal "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8", | |
294 | revs1[10].parents[0] |
|
298 | revs1[10].parents[0] | |
295 | assert_equal "7e61ac704deecde634b51e59daa8110435dcb3da", |
|
299 | assert_equal "7e61ac704deecde634b51e59daa8110435dcb3da", | |
296 | revs1[10].parents[1] |
|
300 | revs1[10].parents[1] | |
297 | end |
|
301 | end | |
298 |
|
302 | |||
299 | def test_getting_revisions_with_leading_and_trailing_spaces_in_filename |
|
303 | def test_getting_revisions_with_leading_and_trailing_spaces_in_filename | |
300 | assert_equal " filename with a leading space.txt ", |
|
304 | assert_equal " filename with a leading space.txt ", | |
301 | @adapter.revisions(" filename with a leading space.txt ", |
|
305 | @adapter.revisions(" filename with a leading space.txt ", | |
302 | nil, "master")[0].paths[0][:path] |
|
306 | nil, "master")[0].paths[0][:path] | |
303 | end |
|
307 | end | |
304 |
|
308 | |||
305 | def test_getting_entries_with_leading_and_trailing_spaces_in_filename |
|
309 | def test_getting_entries_with_leading_and_trailing_spaces_in_filename | |
306 | assert_equal " filename with a leading space.txt ", |
|
310 | assert_equal " filename with a leading space.txt ", | |
307 | @adapter.entries('', |
|
311 | @adapter.entries('', | |
308 | '83ca5fd546063a3c7dc2e568ba3355661a9e2b2c')[3].name |
|
312 | '83ca5fd546063a3c7dc2e568ba3355661a9e2b2c')[3].name | |
309 | end |
|
313 | end | |
310 |
|
314 | |||
311 | def test_annotate |
|
315 | def test_annotate | |
312 | annotate = @adapter.annotate('sources/watchers_controller.rb') |
|
316 | annotate = @adapter.annotate('sources/watchers_controller.rb') | |
313 | assert_kind_of Redmine::Scm::Adapters::Annotate, annotate |
|
317 | assert_kind_of Redmine::Scm::Adapters::Annotate, annotate | |
314 | assert_equal 41, annotate.lines.size |
|
318 | assert_equal 41, annotate.lines.size | |
315 | assert_equal "# This program is free software; you can redistribute it and/or", |
|
319 | assert_equal "# This program is free software; you can redistribute it and/or", | |
316 | annotate.lines[4].strip |
|
320 | annotate.lines[4].strip | |
317 | assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", |
|
321 | assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", | |
318 | annotate.revisions[4].identifier |
|
322 | annotate.revisions[4].identifier | |
319 | assert_equal "jsmith", annotate.revisions[4].author |
|
323 | assert_equal "jsmith", annotate.revisions[4].author | |
320 | end |
|
324 | end | |
321 |
|
325 | |||
322 | def test_annotate_moved_file |
|
326 | def test_annotate_moved_file | |
323 | annotate = @adapter.annotate('renamed_test.txt') |
|
327 | annotate = @adapter.annotate('renamed_test.txt') | |
324 | assert_kind_of Redmine::Scm::Adapters::Annotate, annotate |
|
328 | assert_kind_of Redmine::Scm::Adapters::Annotate, annotate | |
325 | assert_equal 2, annotate.lines.size |
|
329 | assert_equal 2, annotate.lines.size | |
326 | end |
|
330 | end | |
327 |
|
331 | |||
328 | def test_last_rev |
|
332 | def test_last_rev | |
329 | last_rev = @adapter.lastrev("README", |
|
333 | last_rev = @adapter.lastrev("README", | |
330 | "4f26664364207fa8b1af9f8722647ab2d4ac5d43") |
|
334 | "4f26664364207fa8b1af9f8722647ab2d4ac5d43") | |
331 | assert_equal "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8", last_rev.scmid |
|
335 | assert_equal "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8", last_rev.scmid | |
332 | assert_equal "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8", last_rev.identifier |
|
336 | assert_equal "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8", last_rev.identifier | |
333 | assert_equal "Adam Soltys <asoltys@gmail.com>", last_rev.author |
|
337 | assert_equal "Adam Soltys <asoltys@gmail.com>", last_rev.author | |
334 | assert_equal "2009-06-24 05:27:38".to_time, last_rev.time |
|
338 | assert_equal "2009-06-24 05:27:38".to_time, last_rev.time | |
335 | end |
|
339 | end | |
336 |
|
340 | |||
337 | def test_last_rev_with_spaces_in_filename |
|
341 | def test_last_rev_with_spaces_in_filename | |
338 | last_rev = @adapter.lastrev("filemane with spaces.txt", |
|
342 | last_rev = @adapter.lastrev("filemane with spaces.txt", | |
339 | "ed5bb786bbda2dee66a2d50faf51429dbc043a7b") |
|
343 | "ed5bb786bbda2dee66a2d50faf51429dbc043a7b") | |
340 | str_felix_utf8 = FELIX_UTF8.dup |
|
344 | str_felix_utf8 = FELIX_UTF8.dup | |
341 | str_felix_hex = FELIX_HEX.dup |
|
345 | str_felix_hex = FELIX_HEX.dup | |
342 | last_rev_author = last_rev.author |
|
346 | last_rev_author = last_rev.author | |
343 | if last_rev_author.respond_to?(:force_encoding) |
|
347 | if last_rev_author.respond_to?(:force_encoding) | |
344 | last_rev_author.force_encoding('UTF-8') |
|
348 | last_rev_author.force_encoding('UTF-8') | |
345 | end |
|
349 | end | |
346 | assert_equal "ed5bb786bbda2dee66a2d50faf51429dbc043a7b", last_rev.scmid |
|
350 | assert_equal "ed5bb786bbda2dee66a2d50faf51429dbc043a7b", last_rev.scmid | |
347 | assert_equal "ed5bb786bbda2dee66a2d50faf51429dbc043a7b", last_rev.identifier |
|
351 | assert_equal "ed5bb786bbda2dee66a2d50faf51429dbc043a7b", last_rev.identifier | |
348 | assert_equal "#{str_felix_utf8} <felix@fachschaften.org>", |
|
352 | assert_equal "#{str_felix_utf8} <felix@fachschaften.org>", | |
349 | last_rev.author |
|
353 | last_rev.author | |
350 | assert_equal "#{str_felix_hex} <felix@fachschaften.org>", |
|
354 | assert_equal "#{str_felix_hex} <felix@fachschaften.org>", | |
351 | last_rev.author |
|
355 | last_rev.author | |
352 | assert_equal "2010-09-18 19:59:46".to_time, last_rev.time |
|
356 | assert_equal "2010-09-18 19:59:46".to_time, last_rev.time | |
353 | end |
|
357 | end | |
354 |
|
358 | |||
355 | def test_latin_1_path |
|
359 | def test_latin_1_path | |
356 | if WINDOWS_PASS |
|
360 | if WINDOWS_PASS | |
357 | # |
|
361 | # | |
358 | elsif JRUBY_SKIP |
|
362 | elsif JRUBY_SKIP | |
359 | puts JRUBY_SKIP_STR |
|
363 | puts JRUBY_SKIP_STR | |
360 | else |
|
364 | else | |
361 | p2 = "latin-1-dir/test-#{@char_1}-2.txt" |
|
365 | p2 = "latin-1-dir/test-#{@char_1}-2.txt" | |
362 | ['4fc55c43bf3d3dc2efb66145365ddc17639ce81e', '4fc55c43bf3'].each do |r1| |
|
366 | ['4fc55c43bf3d3dc2efb66145365ddc17639ce81e', '4fc55c43bf3'].each do |r1| | |
363 | assert @adapter.diff(p2, r1) |
|
367 | assert @adapter.diff(p2, r1) | |
364 | assert @adapter.cat(p2, r1) |
|
368 | assert @adapter.cat(p2, r1) | |
365 | assert_equal 1, @adapter.annotate(p2, r1).lines.length |
|
369 | assert_equal 1, @adapter.annotate(p2, r1).lines.length | |
366 | ['64f1f3e89ad1cb57976ff0ad99a107012ba3481d', '64f1f3e89ad1cb5797'].each do |r2| |
|
370 | ['64f1f3e89ad1cb57976ff0ad99a107012ba3481d', '64f1f3e89ad1cb5797'].each do |r2| | |
367 | assert @adapter.diff(p2, r1, r2) |
|
371 | assert @adapter.diff(p2, r1, r2) | |
368 | end |
|
372 | end | |
369 | end |
|
373 | end | |
370 | end |
|
374 | end | |
371 | end |
|
375 | end | |
372 |
|
376 | |||
373 | def test_entries_tag |
|
377 | def test_entries_tag | |
374 | entries1 = @adapter.entries(nil, 'tag01.annotated', |
|
378 | entries1 = @adapter.entries(nil, 'tag01.annotated', | |
375 | options = {:report_last_commit => true}) |
|
379 | options = {:report_last_commit => true}) | |
376 | assert entries1 |
|
380 | assert entries1 | |
377 | assert_equal 3, entries1.size |
|
381 | assert_equal 3, entries1.size | |
378 | assert_equal 'sources', entries1[1].name |
|
382 | assert_equal 'sources', entries1[1].name | |
379 | assert_equal 'sources', entries1[1].path |
|
383 | assert_equal 'sources', entries1[1].path | |
380 | assert_equal 'dir', entries1[1].kind |
|
384 | assert_equal 'dir', entries1[1].kind | |
381 | readme = entries1[2] |
|
385 | readme = entries1[2] | |
382 | assert_equal 'README', readme.name |
|
386 | assert_equal 'README', readme.name | |
383 | assert_equal 'README', readme.path |
|
387 | assert_equal 'README', readme.path | |
384 | assert_equal 'file', readme.kind |
|
388 | assert_equal 'file', readme.kind | |
385 | assert_equal 27, readme.size |
|
389 | assert_equal 27, readme.size | |
386 | assert_equal '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', readme.lastrev.identifier |
|
390 | assert_equal '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', readme.lastrev.identifier | |
387 | assert_equal Time.gm(2007, 12, 14, 9, 24, 1), readme.lastrev.time |
|
391 | assert_equal Time.gm(2007, 12, 14, 9, 24, 1), readme.lastrev.time | |
388 | end |
|
392 | end | |
389 |
|
393 | |||
390 | def test_entries_branch |
|
394 | def test_entries_branch | |
391 | entries1 = @adapter.entries(nil, 'test_branch', |
|
395 | entries1 = @adapter.entries(nil, 'test_branch', | |
392 | options = {:report_last_commit => true}) |
|
396 | options = {:report_last_commit => true}) | |
393 | assert entries1 |
|
397 | assert entries1 | |
394 | assert_equal 4, entries1.size |
|
398 | assert_equal 4, entries1.size | |
395 | assert_equal 'sources', entries1[1].name |
|
399 | assert_equal 'sources', entries1[1].name | |
396 | assert_equal 'sources', entries1[1].path |
|
400 | assert_equal 'sources', entries1[1].path | |
397 | assert_equal 'dir', entries1[1].kind |
|
401 | assert_equal 'dir', entries1[1].kind | |
398 | readme = entries1[2] |
|
402 | readme = entries1[2] | |
399 | assert_equal 'README', readme.name |
|
403 | assert_equal 'README', readme.name | |
400 | assert_equal 'README', readme.path |
|
404 | assert_equal 'README', readme.path | |
401 | assert_equal 'file', readme.kind |
|
405 | assert_equal 'file', readme.kind | |
402 | assert_equal 159, readme.size |
|
406 | assert_equal 159, readme.size | |
403 | assert_equal '713f4944648826f558cf548222f813dabe7cbb04', readme.lastrev.identifier |
|
407 | assert_equal '713f4944648826f558cf548222f813dabe7cbb04', readme.lastrev.identifier | |
404 | assert_equal Time.gm(2009, 6, 19, 4, 37, 23), readme.lastrev.time |
|
408 | assert_equal Time.gm(2009, 6, 19, 4, 37, 23), readme.lastrev.time | |
405 | end |
|
409 | end | |
406 |
|
410 | |||
407 | def test_entries_latin_1_files |
|
411 | def test_entries_latin_1_files | |
408 | entries1 = @adapter.entries('latin-1-dir', '64f1f3e8') |
|
412 | entries1 = @adapter.entries('latin-1-dir', '64f1f3e8') | |
409 | assert entries1 |
|
413 | assert entries1 | |
410 | assert_equal 3, entries1.size |
|
414 | assert_equal 3, entries1.size | |
411 | f1 = entries1[1] |
|
415 | f1 = entries1[1] | |
412 | assert_equal "test-#{@char_1}-2.txt", f1.name |
|
416 | assert_equal "test-#{@char_1}-2.txt", f1.name | |
413 | assert_equal "latin-1-dir/test-#{@char_1}-2.txt", f1.path |
|
417 | assert_equal "latin-1-dir/test-#{@char_1}-2.txt", f1.path | |
414 | assert_equal 'file', f1.kind |
|
418 | assert_equal 'file', f1.kind | |
415 | end |
|
419 | end | |
416 |
|
420 | |||
417 | def test_entries_latin_1_dir |
|
421 | def test_entries_latin_1_dir | |
418 | if WINDOWS_PASS |
|
422 | if WINDOWS_PASS | |
419 | # |
|
423 | # | |
420 | elsif JRUBY_SKIP |
|
424 | elsif JRUBY_SKIP | |
421 | puts JRUBY_SKIP_STR |
|
425 | puts JRUBY_SKIP_STR | |
422 | else |
|
426 | else | |
423 | entries1 = @adapter.entries("latin-1-dir/test-#{@char_1}-subdir", |
|
427 | entries1 = @adapter.entries("latin-1-dir/test-#{@char_1}-subdir", | |
424 | '1ca7f5ed') |
|
428 | '1ca7f5ed') | |
425 | assert entries1 |
|
429 | assert entries1 | |
426 | assert_equal 3, entries1.size |
|
430 | assert_equal 3, entries1.size | |
427 | f1 = entries1[1] |
|
431 | f1 = entries1[1] | |
428 | assert_equal "test-#{@char_1}-2.txt", f1.name |
|
432 | assert_equal "test-#{@char_1}-2.txt", f1.name | |
429 | assert_equal "latin-1-dir/test-#{@char_1}-subdir/test-#{@char_1}-2.txt", f1.path |
|
433 | assert_equal "latin-1-dir/test-#{@char_1}-subdir/test-#{@char_1}-2.txt", f1.path | |
430 | assert_equal 'file', f1.kind |
|
434 | assert_equal 'file', f1.kind | |
431 | end |
|
435 | end | |
432 | end |
|
436 | end | |
433 |
|
437 | |||
434 | def test_path_encoding_default_utf8 |
|
438 | def test_path_encoding_default_utf8 | |
435 | adpt1 = Redmine::Scm::Adapters::GitAdapter.new( |
|
439 | adpt1 = Redmine::Scm::Adapters::GitAdapter.new( | |
436 | REPOSITORY_PATH |
|
440 | REPOSITORY_PATH | |
437 | ) |
|
441 | ) | |
438 | assert_equal "UTF-8", adpt1.path_encoding |
|
442 | assert_equal "UTF-8", adpt1.path_encoding | |
439 | adpt2 = Redmine::Scm::Adapters::GitAdapter.new( |
|
443 | adpt2 = Redmine::Scm::Adapters::GitAdapter.new( | |
440 | REPOSITORY_PATH, |
|
444 | REPOSITORY_PATH, | |
441 | nil, |
|
445 | nil, | |
442 | nil, |
|
446 | nil, | |
443 | nil, |
|
447 | nil, | |
444 | "" |
|
448 | "" | |
445 | ) |
|
449 | ) | |
446 | assert_equal "UTF-8", adpt2.path_encoding |
|
450 | assert_equal "UTF-8", adpt2.path_encoding | |
447 | end |
|
451 | end | |
448 |
|
452 | |||
449 | def test_cat_path_invalid |
|
453 | def test_cat_path_invalid | |
450 | assert_nil @adapter.cat('invalid') |
|
454 | assert_nil @adapter.cat('invalid') | |
451 | end |
|
455 | end | |
452 |
|
456 | |||
453 | def test_cat_revision_invalid |
|
457 | def test_cat_revision_invalid | |
454 | assert @adapter.cat('README') |
|
458 | assert @adapter.cat('README') | |
455 | assert_nil @adapter.cat('README', 'abcd1234efgh') |
|
459 | assert_nil @adapter.cat('README', 'abcd1234efgh') | |
456 | end |
|
460 | end | |
457 |
|
461 | |||
458 | def test_diff_path_invalid |
|
462 | def test_diff_path_invalid | |
459 | assert_equal [], @adapter.diff('invalid', '713f4944648826f5') |
|
463 | assert_equal [], @adapter.diff('invalid', '713f4944648826f5') | |
460 | end |
|
464 | end | |
461 |
|
465 | |||
462 | def test_diff_revision_invalid |
|
466 | def test_diff_revision_invalid | |
463 | assert_nil @adapter.diff(nil, 'abcd1234efgh') |
|
467 | assert_nil @adapter.diff(nil, 'abcd1234efgh') | |
464 | assert_nil @adapter.diff(nil, '713f4944648826f5', 'abcd1234efgh') |
|
468 | assert_nil @adapter.diff(nil, '713f4944648826f5', 'abcd1234efgh') | |
465 | assert_nil @adapter.diff(nil, 'abcd1234efgh', '713f4944648826f5') |
|
469 | assert_nil @adapter.diff(nil, 'abcd1234efgh', '713f4944648826f5') | |
466 | end |
|
470 | end | |
467 |
|
471 | |||
468 | def test_annotate_path_invalid |
|
472 | def test_annotate_path_invalid | |
469 | assert_nil @adapter.annotate('invalid') |
|
473 | assert_nil @adapter.annotate('invalid') | |
470 | end |
|
474 | end | |
471 |
|
475 | |||
472 | def test_annotate_revision_invalid |
|
476 | def test_annotate_revision_invalid | |
473 | assert @adapter.annotate('README') |
|
477 | assert @adapter.annotate('README') | |
474 | assert_nil @adapter.annotate('README', 'abcd1234efgh') |
|
478 | assert_nil @adapter.annotate('README', 'abcd1234efgh') | |
475 | end |
|
479 | end | |
476 |
|
480 | |||
477 | private |
|
481 | private | |
478 |
|
482 | |||
479 | def test_scm_version_for(scm_command_version, version) |
|
483 | def test_scm_version_for(scm_command_version, version) | |
480 | @adapter.class.expects(:scm_version_from_command_line).returns(scm_command_version) |
|
484 | @adapter.class.expects(:scm_version_from_command_line).returns(scm_command_version) | |
481 | assert_equal version, @adapter.class.scm_command_version |
|
485 | assert_equal version, @adapter.class.scm_command_version | |
482 | end |
|
486 | end | |
483 |
|
487 | |||
484 | else |
|
488 | else | |
485 | puts "Git test repository NOT FOUND. Skipping unit tests !!!" |
|
489 | puts "Git test repository NOT FOUND. Skipping unit tests !!!" | |
486 | def test_fake; assert true end |
|
490 | def test_fake; assert true end | |
487 | end |
|
491 | end | |
488 | end |
|
492 | end | |
489 |
|
493 | |||
490 | rescue LoadError |
|
494 | rescue LoadError | |
491 | class GitMochaFake < ActiveSupport::TestCase |
|
495 | class GitMochaFake < ActiveSupport::TestCase | |
492 | def test_fake; assert(false, "Requires mocha to run those tests") end |
|
496 | def test_fake; assert(false, "Requires mocha to run those tests") end | |
493 | end |
|
497 | end | |
494 | end |
|
498 | end |
@@ -1,515 +1,513 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | require File.expand_path('../../test_helper', __FILE__) |
|
18 | require File.expand_path('../../test_helper', __FILE__) | |
19 |
|
19 | |||
20 | class RepositoryGitTest < ActiveSupport::TestCase |
|
20 | class RepositoryGitTest < ActiveSupport::TestCase | |
21 | fixtures :projects, :repositories, :enabled_modules, :users, :roles |
|
21 | fixtures :projects, :repositories, :enabled_modules, :users, :roles | |
22 |
|
22 | |||
23 | REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s |
|
23 | REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s | |
24 | REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin? |
|
24 | REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin? | |
25 |
|
25 | |||
26 |
NUM_REV = 2 |
|
26 | NUM_REV = 28 | |
27 |
|
27 | |||
28 | FELIX_HEX = "Felix Sch\xC3\xA4fer" |
|
28 | FELIX_HEX = "Felix Sch\xC3\xA4fer" | |
29 | CHAR_1_HEX = "\xc3\x9c" |
|
29 | CHAR_1_HEX = "\xc3\x9c" | |
30 |
|
30 | |||
31 | ## Ruby uses ANSI api to fork a process on Windows. |
|
31 | ## Ruby uses ANSI api to fork a process on Windows. | |
32 | ## Japanese Shift_JIS and Traditional Chinese Big5 have 0x5c(backslash) problem |
|
32 | ## Japanese Shift_JIS and Traditional Chinese Big5 have 0x5c(backslash) problem | |
33 | ## and these are incompatible with ASCII. |
|
33 | ## and these are incompatible with ASCII. | |
34 | # WINDOWS_PASS = Redmine::Platform.mswin? |
|
34 | # WINDOWS_PASS = Redmine::Platform.mswin? | |
35 | WINDOWS_PASS = false |
|
35 | WINDOWS_PASS = false | |
36 |
|
36 | |||
37 | ## Git, Mercurial and CVS path encodings are binary. |
|
37 | ## Git, Mercurial and CVS path encodings are binary. | |
38 | ## Subversion supports URL encoding for path. |
|
38 | ## Subversion supports URL encoding for path. | |
39 | ## Redmine Mercurial adapter and extension use URL encoding. |
|
39 | ## Redmine Mercurial adapter and extension use URL encoding. | |
40 | ## Git accepts only binary path in command line parameter. |
|
40 | ## Git accepts only binary path in command line parameter. | |
41 | ## So, there is no way to use binary command line parameter in JRuby. |
|
41 | ## So, there is no way to use binary command line parameter in JRuby. | |
42 | JRUBY_SKIP = (RUBY_PLATFORM == 'java') |
|
42 | JRUBY_SKIP = (RUBY_PLATFORM == 'java') | |
43 | JRUBY_SKIP_STR = "TODO: This test fails in JRuby" |
|
43 | JRUBY_SKIP_STR = "TODO: This test fails in JRuby" | |
44 |
|
44 | |||
45 | if File.directory?(REPOSITORY_PATH) |
|
45 | if File.directory?(REPOSITORY_PATH) | |
46 | def setup |
|
46 | def setup | |
47 | klass = Repository::Git |
|
47 | klass = Repository::Git | |
48 | assert_equal "Git", klass.scm_name |
|
48 | assert_equal "Git", klass.scm_name | |
49 | assert klass.scm_adapter_class |
|
49 | assert klass.scm_adapter_class | |
50 | assert_not_equal "", klass.scm_command |
|
50 | assert_not_equal "", klass.scm_command | |
51 | assert_equal true, klass.scm_available |
|
51 | assert_equal true, klass.scm_available | |
52 |
|
52 | |||
53 | @project = Project.find(3) |
|
53 | @project = Project.find(3) | |
54 | @repository = Repository::Git.create( |
|
54 | @repository = Repository::Git.create( | |
55 | :project => @project, |
|
55 | :project => @project, | |
56 | :url => REPOSITORY_PATH, |
|
56 | :url => REPOSITORY_PATH, | |
57 | :path_encoding => 'ISO-8859-1' |
|
57 | :path_encoding => 'ISO-8859-1' | |
58 | ) |
|
58 | ) | |
59 | assert @repository |
|
59 | assert @repository | |
60 | @char_1 = CHAR_1_HEX.dup |
|
60 | @char_1 = CHAR_1_HEX.dup | |
61 | if @char_1.respond_to?(:force_encoding) |
|
61 | if @char_1.respond_to?(:force_encoding) | |
62 | @char_1.force_encoding('UTF-8') |
|
62 | @char_1.force_encoding('UTF-8') | |
63 | end |
|
63 | end | |
64 | end |
|
64 | end | |
65 |
|
65 | |||
66 | def test_fetch_changesets_from_scratch |
|
66 | def test_fetch_changesets_from_scratch | |
67 | assert_nil @repository.extra_info |
|
67 | assert_nil @repository.extra_info | |
68 |
|
68 | |||
69 | assert_equal 0, @repository.changesets.count |
|
69 | assert_equal 0, @repository.changesets.count | |
70 | @repository.fetch_changesets |
|
70 | @repository.fetch_changesets | |
71 | @project.reload |
|
71 | @project.reload | |
72 |
|
72 | |||
73 | assert_equal NUM_REV, @repository.changesets.count |
|
73 | assert_equal NUM_REV, @repository.changesets.count | |
74 |
assert_equal 3 |
|
74 | assert_equal 39, @repository.changes.count | |
75 |
|
75 | |||
76 | commit = @repository.changesets.find(:first, :order => 'committed_on ASC') |
|
76 | commit = @repository.changesets.find(:first, :order => 'committed_on ASC') | |
77 | assert_equal "Initial import.\nThe repository contains 3 files.", commit.comments |
|
77 | assert_equal "Initial import.\nThe repository contains 3 files.", commit.comments | |
78 | assert_equal "jsmith <jsmith@foo.bar>", commit.committer |
|
78 | assert_equal "jsmith <jsmith@foo.bar>", commit.committer | |
79 | assert_equal User.find_by_login('jsmith'), commit.user |
|
79 | assert_equal User.find_by_login('jsmith'), commit.user | |
80 | # TODO: add a commit with commit time <> author time to the test repository |
|
80 | # TODO: add a commit with commit time <> author time to the test repository | |
81 | assert_equal "2007-12-14 09:22:52".to_time, commit.committed_on |
|
81 | assert_equal "2007-12-14 09:22:52".to_time, commit.committed_on | |
82 | assert_equal "2007-12-14".to_date, commit.commit_date |
|
82 | assert_equal "2007-12-14".to_date, commit.commit_date | |
83 | assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", commit.revision |
|
83 | assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", commit.revision | |
84 | assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", commit.scmid |
|
84 | assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", commit.scmid | |
85 | assert_equal 3, commit.changes.count |
|
85 | assert_equal 3, commit.changes.count | |
86 | change = commit.changes.sort_by(&:path).first |
|
86 | change = commit.changes.sort_by(&:path).first | |
87 | assert_equal "README", change.path |
|
87 | assert_equal "README", change.path | |
88 | assert_equal "A", change.action |
|
88 | assert_equal "A", change.action | |
89 |
|
89 | |||
90 |
assert_equal |
|
90 | assert_equal 5, @repository.extra_info["branches"].size | |
91 | end |
|
91 | end | |
92 |
|
92 | |||
93 | def test_fetch_changesets_incremental |
|
93 | def test_fetch_changesets_incremental | |
94 | assert_equal 0, @repository.changesets.count |
|
94 | assert_equal 0, @repository.changesets.count | |
95 | @repository.fetch_changesets |
|
95 | @repository.fetch_changesets | |
96 | @project.reload |
|
96 | @project.reload | |
97 | assert_equal NUM_REV, @repository.changesets.count |
|
97 | assert_equal NUM_REV, @repository.changesets.count | |
98 | assert_equal 33, @repository.changes.count |
|
|||
99 | extra_info_db = @repository.extra_info["branches"] |
|
98 | extra_info_db = @repository.extra_info["branches"] | |
100 | assert_equal 4, extra_info_db.size |
|
|||
101 | assert_equal "1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127", |
|
99 | assert_equal "1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127", | |
102 | extra_info_db["latin-1-path-encoding"]["last_scmid"] |
|
100 | extra_info_db["latin-1-path-encoding"]["last_scmid"] | |
103 | assert_equal "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c", |
|
101 | assert_equal "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c", | |
104 | extra_info_db["master"]["last_scmid"] |
|
102 | extra_info_db["master"]["last_scmid"] | |
105 |
|
103 | |||
106 | del_revs = [ |
|
104 | del_revs = [ | |
107 | "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c", |
|
105 | "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c", | |
108 | "ed5bb786bbda2dee66a2d50faf51429dbc043a7b", |
|
106 | "ed5bb786bbda2dee66a2d50faf51429dbc043a7b", | |
109 | "4f26664364207fa8b1af9f8722647ab2d4ac5d43", |
|
107 | "4f26664364207fa8b1af9f8722647ab2d4ac5d43", | |
110 | "deff712f05a90d96edbd70facc47d944be5897e3", |
|
108 | "deff712f05a90d96edbd70facc47d944be5897e3", | |
111 | "32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf", |
|
109 | "32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf", | |
112 | "7e61ac704deecde634b51e59daa8110435dcb3da", |
|
110 | "7e61ac704deecde634b51e59daa8110435dcb3da", | |
113 | ] |
|
111 | ] | |
114 | @repository.changesets.each do |rev| |
|
112 | @repository.changesets.each do |rev| | |
115 | rev.destroy if del_revs.detect {|r| r == rev.scmid.to_s } |
|
113 | rev.destroy if del_revs.detect {|r| r == rev.scmid.to_s } | |
116 | end |
|
114 | end | |
117 | @project.reload |
|
115 | @project.reload | |
118 | cs1 = @repository.changesets |
|
116 | cs1 = @repository.changesets | |
119 |
assert_equal |
|
117 | assert_equal 22, cs1.count | |
120 | h = @repository.extra_info.dup |
|
118 | h = @repository.extra_info.dup | |
121 | h["branches"]["master"]["last_scmid"] = |
|
119 | h["branches"]["master"]["last_scmid"] = | |
122 | "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8" |
|
120 | "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8" | |
123 | @repository.merge_extra_info(h) |
|
121 | @repository.merge_extra_info(h) | |
124 | @repository.save |
|
122 | @repository.save | |
125 | @project.reload |
|
123 | @project.reload | |
126 | extra_info_db_1 = @repository.extra_info["branches"] |
|
124 | extra_info_db_1 = @repository.extra_info["branches"] | |
127 | assert_equal "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8", |
|
125 | assert_equal "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8", | |
128 | extra_info_db_1["master"]["last_scmid"] |
|
126 | extra_info_db_1["master"]["last_scmid"] | |
129 |
|
127 | |||
130 | @repository.fetch_changesets |
|
128 | @repository.fetch_changesets | |
131 | @project.reload |
|
129 | @project.reload | |
132 | assert_equal NUM_REV, @repository.changesets.count |
|
130 | assert_equal NUM_REV, @repository.changesets.count | |
133 | end |
|
131 | end | |
134 |
|
132 | |||
135 | def test_fetch_changesets_invalid_rev |
|
133 | def test_fetch_changesets_invalid_rev | |
136 | assert_equal 0, @repository.changesets.count |
|
134 | assert_equal 0, @repository.changesets.count | |
137 | @repository.fetch_changesets |
|
135 | @repository.fetch_changesets | |
138 | @project.reload |
|
136 | @project.reload | |
139 | assert_equal NUM_REV, @repository.changesets.count |
|
137 | assert_equal NUM_REV, @repository.changesets.count | |
140 | extra_info_db = @repository.extra_info["branches"] |
|
138 | extra_info_db = @repository.extra_info["branches"] | |
141 |
assert_equal |
|
139 | assert_equal 5, extra_info_db.size | |
142 | assert_equal "1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127", |
|
140 | assert_equal "1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127", | |
143 | extra_info_db["latin-1-path-encoding"]["last_scmid"] |
|
141 | extra_info_db["latin-1-path-encoding"]["last_scmid"] | |
144 | assert_equal "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c", |
|
142 | assert_equal "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c", | |
145 | extra_info_db["master"]["last_scmid"] |
|
143 | extra_info_db["master"]["last_scmid"] | |
146 |
|
144 | |||
147 | del_revs = [ |
|
145 | del_revs = [ | |
148 | "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c", |
|
146 | "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c", | |
149 | "ed5bb786bbda2dee66a2d50faf51429dbc043a7b", |
|
147 | "ed5bb786bbda2dee66a2d50faf51429dbc043a7b", | |
150 | "4f26664364207fa8b1af9f8722647ab2d4ac5d43", |
|
148 | "4f26664364207fa8b1af9f8722647ab2d4ac5d43", | |
151 | "deff712f05a90d96edbd70facc47d944be5897e3", |
|
149 | "deff712f05a90d96edbd70facc47d944be5897e3", | |
152 | "32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf", |
|
150 | "32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf", | |
153 | "7e61ac704deecde634b51e59daa8110435dcb3da", |
|
151 | "7e61ac704deecde634b51e59daa8110435dcb3da", | |
154 | ] |
|
152 | ] | |
155 | @repository.changesets.each do |rev| |
|
153 | @repository.changesets.each do |rev| | |
156 | rev.destroy if del_revs.detect {|r| r == rev.scmid.to_s } |
|
154 | rev.destroy if del_revs.detect {|r| r == rev.scmid.to_s } | |
157 | end |
|
155 | end | |
158 | @project.reload |
|
156 | @project.reload | |
159 | cs1 = @repository.changesets |
|
157 | cs1 = @repository.changesets | |
160 |
assert_equal |
|
158 | assert_equal 22, cs1.count | |
161 | h = @repository.extra_info.dup |
|
159 | h = @repository.extra_info.dup | |
162 | h["branches"]["master"]["last_scmid"] = |
|
160 | h["branches"]["master"]["last_scmid"] = | |
163 | "abcd1234efgh" |
|
161 | "abcd1234efgh" | |
164 | @repository.merge_extra_info(h) |
|
162 | @repository.merge_extra_info(h) | |
165 | @repository.save |
|
163 | @repository.save | |
166 | @project.reload |
|
164 | @project.reload | |
167 | extra_info_db_1 = @repository.extra_info["branches"] |
|
165 | extra_info_db_1 = @repository.extra_info["branches"] | |
168 | assert_equal "abcd1234efgh", |
|
166 | assert_equal "abcd1234efgh", | |
169 | extra_info_db_1["master"]["last_scmid"] |
|
167 | extra_info_db_1["master"]["last_scmid"] | |
170 |
|
168 | |||
171 | @repository.fetch_changesets |
|
169 | @repository.fetch_changesets | |
172 | @project.reload |
|
170 | @project.reload | |
173 |
assert_equal |
|
171 | assert_equal 22, @repository.changesets.count | |
174 | end |
|
172 | end | |
175 |
|
173 | |||
176 | def test_parents |
|
174 | def test_parents | |
177 | assert_equal 0, @repository.changesets.count |
|
175 | assert_equal 0, @repository.changesets.count | |
178 | @repository.fetch_changesets |
|
176 | @repository.fetch_changesets | |
179 | @project.reload |
|
177 | @project.reload | |
180 | assert_equal NUM_REV, @repository.changesets.count |
|
178 | assert_equal NUM_REV, @repository.changesets.count | |
181 | r1 = @repository.find_changeset_by_name("7234cb2750b63") |
|
179 | r1 = @repository.find_changeset_by_name("7234cb2750b63") | |
182 | assert_equal [], r1.parents |
|
180 | assert_equal [], r1.parents | |
183 | r2 = @repository.find_changeset_by_name("899a15dba03a3") |
|
181 | r2 = @repository.find_changeset_by_name("899a15dba03a3") | |
184 | assert_equal 1, r2.parents.length |
|
182 | assert_equal 1, r2.parents.length | |
185 | assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", |
|
183 | assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", | |
186 | r2.parents[0].identifier |
|
184 | r2.parents[0].identifier | |
187 | r3 = @repository.find_changeset_by_name("32ae898b720c2") |
|
185 | r3 = @repository.find_changeset_by_name("32ae898b720c2") | |
188 | assert_equal 2, r3.parents.length |
|
186 | assert_equal 2, r3.parents.length | |
189 | r4 = [r3.parents[0].identifier, r3.parents[1].identifier].sort |
|
187 | r4 = [r3.parents[0].identifier, r3.parents[1].identifier].sort | |
190 | assert_equal "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8", r4[0] |
|
188 | assert_equal "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8", r4[0] | |
191 | assert_equal "7e61ac704deecde634b51e59daa8110435dcb3da", r4[1] |
|
189 | assert_equal "7e61ac704deecde634b51e59daa8110435dcb3da", r4[1] | |
192 | end |
|
190 | end | |
193 |
|
191 | |||
194 | def test_db_consistent_ordering_init |
|
192 | def test_db_consistent_ordering_init | |
195 | assert_nil @repository.extra_info |
|
193 | assert_nil @repository.extra_info | |
196 | assert_equal 0, @repository.changesets.count |
|
194 | assert_equal 0, @repository.changesets.count | |
197 | @repository.fetch_changesets |
|
195 | @repository.fetch_changesets | |
198 | @project.reload |
|
196 | @project.reload | |
199 | assert_equal 1, @repository.extra_info["db_consistent"]["ordering"] |
|
197 | assert_equal 1, @repository.extra_info["db_consistent"]["ordering"] | |
200 | end |
|
198 | end | |
201 |
|
199 | |||
202 | def test_db_consistent_ordering_before_1_2 |
|
200 | def test_db_consistent_ordering_before_1_2 | |
203 | assert_nil @repository.extra_info |
|
201 | assert_nil @repository.extra_info | |
204 | assert_equal 0, @repository.changesets.count |
|
202 | assert_equal 0, @repository.changesets.count | |
205 | @repository.fetch_changesets |
|
203 | @repository.fetch_changesets | |
206 | @project.reload |
|
204 | @project.reload | |
207 | assert_equal NUM_REV, @repository.changesets.count |
|
205 | assert_equal NUM_REV, @repository.changesets.count | |
208 | assert_not_nil @repository.extra_info |
|
206 | assert_not_nil @repository.extra_info | |
209 | @repository.write_attribute(:extra_info, nil) |
|
207 | @repository.write_attribute(:extra_info, nil) | |
210 | @repository.save |
|
208 | @repository.save | |
211 | assert_nil @repository.extra_info |
|
209 | assert_nil @repository.extra_info | |
212 | assert_equal NUM_REV, @repository.changesets.count |
|
210 | assert_equal NUM_REV, @repository.changesets.count | |
213 | @repository.fetch_changesets |
|
211 | @repository.fetch_changesets | |
214 | @project.reload |
|
212 | @project.reload | |
215 | assert_equal 0, @repository.extra_info["db_consistent"]["ordering"] |
|
213 | assert_equal 0, @repository.extra_info["db_consistent"]["ordering"] | |
216 |
|
214 | |||
217 | del_revs = [ |
|
215 | del_revs = [ | |
218 | "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c", |
|
216 | "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c", | |
219 | "ed5bb786bbda2dee66a2d50faf51429dbc043a7b", |
|
217 | "ed5bb786bbda2dee66a2d50faf51429dbc043a7b", | |
220 | "4f26664364207fa8b1af9f8722647ab2d4ac5d43", |
|
218 | "4f26664364207fa8b1af9f8722647ab2d4ac5d43", | |
221 | "deff712f05a90d96edbd70facc47d944be5897e3", |
|
219 | "deff712f05a90d96edbd70facc47d944be5897e3", | |
222 | "32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf", |
|
220 | "32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf", | |
223 | "7e61ac704deecde634b51e59daa8110435dcb3da", |
|
221 | "7e61ac704deecde634b51e59daa8110435dcb3da", | |
224 | ] |
|
222 | ] | |
225 | @repository.changesets.each do |rev| |
|
223 | @repository.changesets.each do |rev| | |
226 | rev.destroy if del_revs.detect {|r| r == rev.scmid.to_s } |
|
224 | rev.destroy if del_revs.detect {|r| r == rev.scmid.to_s } | |
227 | end |
|
225 | end | |
228 | @project.reload |
|
226 | @project.reload | |
229 | cs1 = @repository.changesets |
|
227 | cs1 = @repository.changesets | |
230 |
assert_equal |
|
228 | assert_equal NUM_REV - 6, cs1.count | |
231 | assert_equal 0, @repository.extra_info["db_consistent"]["ordering"] |
|
229 | assert_equal 0, @repository.extra_info["db_consistent"]["ordering"] | |
232 | h = @repository.extra_info.dup |
|
230 | h = @repository.extra_info.dup | |
233 | h["branches"]["master"]["last_scmid"] = |
|
231 | h["branches"]["master"]["last_scmid"] = | |
234 | "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8" |
|
232 | "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8" | |
235 | @repository.merge_extra_info(h) |
|
233 | @repository.merge_extra_info(h) | |
236 | @repository.save |
|
234 | @repository.save | |
237 | @project.reload |
|
235 | @project.reload | |
238 | extra_info_db_1 = @repository.extra_info["branches"] |
|
236 | extra_info_db_1 = @repository.extra_info["branches"] | |
239 | assert_equal "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8", |
|
237 | assert_equal "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8", | |
240 | extra_info_db_1["master"]["last_scmid"] |
|
238 | extra_info_db_1["master"]["last_scmid"] | |
241 |
|
239 | |||
242 | @repository.fetch_changesets |
|
240 | @repository.fetch_changesets | |
243 | assert_equal NUM_REV, @repository.changesets.count |
|
241 | assert_equal NUM_REV, @repository.changesets.count | |
244 | assert_equal 0, @repository.extra_info["db_consistent"]["ordering"] |
|
242 | assert_equal 0, @repository.extra_info["db_consistent"]["ordering"] | |
245 | end |
|
243 | end | |
246 |
|
244 | |||
247 | def test_heads_from_branches_hash |
|
245 | def test_heads_from_branches_hash | |
248 | assert_nil @repository.extra_info |
|
246 | assert_nil @repository.extra_info | |
249 | assert_equal 0, @repository.changesets.count |
|
247 | assert_equal 0, @repository.changesets.count | |
250 | assert_equal [], @repository.heads_from_branches_hash |
|
248 | assert_equal [], @repository.heads_from_branches_hash | |
251 | h = {} |
|
249 | h = {} | |
252 | h["branches"] = {} |
|
250 | h["branches"] = {} | |
253 | h["branches"]["test1"] = {} |
|
251 | h["branches"]["test1"] = {} | |
254 | h["branches"]["test1"]["last_scmid"] = "1234abcd" |
|
252 | h["branches"]["test1"]["last_scmid"] = "1234abcd" | |
255 | h["branches"]["test2"] = {} |
|
253 | h["branches"]["test2"] = {} | |
256 | h["branches"]["test2"]["last_scmid"] = "abcd1234" |
|
254 | h["branches"]["test2"]["last_scmid"] = "abcd1234" | |
257 | @repository.merge_extra_info(h) |
|
255 | @repository.merge_extra_info(h) | |
258 | @repository.save |
|
256 | @repository.save | |
259 | @project.reload |
|
257 | @project.reload | |
260 | assert_equal ["1234abcd", "abcd1234"], @repository.heads_from_branches_hash.sort |
|
258 | assert_equal ["1234abcd", "abcd1234"], @repository.heads_from_branches_hash.sort | |
261 | end |
|
259 | end | |
262 |
|
260 | |||
263 | def test_latest_changesets |
|
261 | def test_latest_changesets | |
264 | assert_equal 0, @repository.changesets.count |
|
262 | assert_equal 0, @repository.changesets.count | |
265 | @repository.fetch_changesets |
|
263 | @repository.fetch_changesets | |
266 | @project.reload |
|
264 | @project.reload | |
267 | assert_equal NUM_REV, @repository.changesets.count |
|
265 | assert_equal NUM_REV, @repository.changesets.count | |
268 | # with limit |
|
266 | # with limit | |
269 | changesets = @repository.latest_changesets('', 'master', 2) |
|
267 | changesets = @repository.latest_changesets('', 'master', 2) | |
270 | assert_equal 2, changesets.size |
|
268 | assert_equal 2, changesets.size | |
271 |
|
269 | |||
272 | # with path |
|
270 | # with path | |
273 | changesets = @repository.latest_changesets('images', 'master') |
|
271 | changesets = @repository.latest_changesets('images', 'master') | |
274 | assert_equal [ |
|
272 | assert_equal [ | |
275 | 'deff712f05a90d96edbd70facc47d944be5897e3', |
|
273 | 'deff712f05a90d96edbd70facc47d944be5897e3', | |
276 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
274 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
277 | '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
275 | '7234cb2750b63f47bff735edc50a1c0a433c2518', | |
278 | ], changesets.collect(&:revision) |
|
276 | ], changesets.collect(&:revision) | |
279 |
|
277 | |||
280 | changesets = @repository.latest_changesets('README', nil) |
|
278 | changesets = @repository.latest_changesets('README', nil) | |
281 | assert_equal [ |
|
279 | assert_equal [ | |
282 | '32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf', |
|
280 | '32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf', | |
283 | '4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8', |
|
281 | '4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8', | |
284 | '713f4944648826f558cf548222f813dabe7cbb04', |
|
282 | '713f4944648826f558cf548222f813dabe7cbb04', | |
285 | '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', |
|
283 | '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', | |
286 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
284 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
287 | '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
285 | '7234cb2750b63f47bff735edc50a1c0a433c2518', | |
288 | ], changesets.collect(&:revision) |
|
286 | ], changesets.collect(&:revision) | |
289 |
|
287 | |||
290 | # with path, revision and limit |
|
288 | # with path, revision and limit | |
291 | changesets = @repository.latest_changesets('images', '899a15dba') |
|
289 | changesets = @repository.latest_changesets('images', '899a15dba') | |
292 | assert_equal [ |
|
290 | assert_equal [ | |
293 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
291 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
294 | '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
292 | '7234cb2750b63f47bff735edc50a1c0a433c2518', | |
295 | ], changesets.collect(&:revision) |
|
293 | ], changesets.collect(&:revision) | |
296 |
|
294 | |||
297 | changesets = @repository.latest_changesets('images', '899a15dba', 1) |
|
295 | changesets = @repository.latest_changesets('images', '899a15dba', 1) | |
298 | assert_equal [ |
|
296 | assert_equal [ | |
299 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
297 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
300 | ], changesets.collect(&:revision) |
|
298 | ], changesets.collect(&:revision) | |
301 |
|
299 | |||
302 | changesets = @repository.latest_changesets('README', '899a15dba') |
|
300 | changesets = @repository.latest_changesets('README', '899a15dba') | |
303 | assert_equal [ |
|
301 | assert_equal [ | |
304 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
302 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
305 | '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
303 | '7234cb2750b63f47bff735edc50a1c0a433c2518', | |
306 | ], changesets.collect(&:revision) |
|
304 | ], changesets.collect(&:revision) | |
307 |
|
305 | |||
308 | changesets = @repository.latest_changesets('README', '899a15dba', 1) |
|
306 | changesets = @repository.latest_changesets('README', '899a15dba', 1) | |
309 | assert_equal [ |
|
307 | assert_equal [ | |
310 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
308 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
311 | ], changesets.collect(&:revision) |
|
309 | ], changesets.collect(&:revision) | |
312 |
|
310 | |||
313 | # with path, tag and limit |
|
311 | # with path, tag and limit | |
314 | changesets = @repository.latest_changesets('images', 'tag01.annotated') |
|
312 | changesets = @repository.latest_changesets('images', 'tag01.annotated') | |
315 | assert_equal [ |
|
313 | assert_equal [ | |
316 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
314 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
317 | '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
315 | '7234cb2750b63f47bff735edc50a1c0a433c2518', | |
318 | ], changesets.collect(&:revision) |
|
316 | ], changesets.collect(&:revision) | |
319 |
|
317 | |||
320 | changesets = @repository.latest_changesets('images', 'tag01.annotated', 1) |
|
318 | changesets = @repository.latest_changesets('images', 'tag01.annotated', 1) | |
321 | assert_equal [ |
|
319 | assert_equal [ | |
322 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
320 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
323 | ], changesets.collect(&:revision) |
|
321 | ], changesets.collect(&:revision) | |
324 |
|
322 | |||
325 | changesets = @repository.latest_changesets('README', 'tag01.annotated') |
|
323 | changesets = @repository.latest_changesets('README', 'tag01.annotated') | |
326 | assert_equal [ |
|
324 | assert_equal [ | |
327 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
325 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
328 | '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
326 | '7234cb2750b63f47bff735edc50a1c0a433c2518', | |
329 | ], changesets.collect(&:revision) |
|
327 | ], changesets.collect(&:revision) | |
330 |
|
328 | |||
331 | changesets = @repository.latest_changesets('README', 'tag01.annotated', 1) |
|
329 | changesets = @repository.latest_changesets('README', 'tag01.annotated', 1) | |
332 | assert_equal [ |
|
330 | assert_equal [ | |
333 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
331 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
334 | ], changesets.collect(&:revision) |
|
332 | ], changesets.collect(&:revision) | |
335 |
|
333 | |||
336 | # with path, branch and limit |
|
334 | # with path, branch and limit | |
337 | changesets = @repository.latest_changesets('images', 'test_branch') |
|
335 | changesets = @repository.latest_changesets('images', 'test_branch') | |
338 | assert_equal [ |
|
336 | assert_equal [ | |
339 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
337 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
340 | '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
338 | '7234cb2750b63f47bff735edc50a1c0a433c2518', | |
341 | ], changesets.collect(&:revision) |
|
339 | ], changesets.collect(&:revision) | |
342 |
|
340 | |||
343 | changesets = @repository.latest_changesets('images', 'test_branch', 1) |
|
341 | changesets = @repository.latest_changesets('images', 'test_branch', 1) | |
344 | assert_equal [ |
|
342 | assert_equal [ | |
345 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
343 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
346 | ], changesets.collect(&:revision) |
|
344 | ], changesets.collect(&:revision) | |
347 |
|
345 | |||
348 | changesets = @repository.latest_changesets('README', 'test_branch') |
|
346 | changesets = @repository.latest_changesets('README', 'test_branch') | |
349 | assert_equal [ |
|
347 | assert_equal [ | |
350 | '713f4944648826f558cf548222f813dabe7cbb04', |
|
348 | '713f4944648826f558cf548222f813dabe7cbb04', | |
351 | '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', |
|
349 | '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', | |
352 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
350 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
353 | '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
351 | '7234cb2750b63f47bff735edc50a1c0a433c2518', | |
354 | ], changesets.collect(&:revision) |
|
352 | ], changesets.collect(&:revision) | |
355 |
|
353 | |||
356 | changesets = @repository.latest_changesets('README', 'test_branch', 2) |
|
354 | changesets = @repository.latest_changesets('README', 'test_branch', 2) | |
357 | assert_equal [ |
|
355 | assert_equal [ | |
358 | '713f4944648826f558cf548222f813dabe7cbb04', |
|
356 | '713f4944648826f558cf548222f813dabe7cbb04', | |
359 | '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', |
|
357 | '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', | |
360 | ], changesets.collect(&:revision) |
|
358 | ], changesets.collect(&:revision) | |
361 |
|
359 | |||
362 | if JRUBY_SKIP |
|
360 | if JRUBY_SKIP | |
363 | puts JRUBY_SKIP_STR |
|
361 | puts JRUBY_SKIP_STR | |
364 | else |
|
362 | else | |
365 | # latin-1 encoding path |
|
363 | # latin-1 encoding path | |
366 | changesets = @repository.latest_changesets( |
|
364 | changesets = @repository.latest_changesets( | |
367 | "latin-1-dir/test-#{@char_1}-2.txt", '64f1f3e89') |
|
365 | "latin-1-dir/test-#{@char_1}-2.txt", '64f1f3e89') | |
368 | assert_equal [ |
|
366 | assert_equal [ | |
369 | '64f1f3e89ad1cb57976ff0ad99a107012ba3481d', |
|
367 | '64f1f3e89ad1cb57976ff0ad99a107012ba3481d', | |
370 | '4fc55c43bf3d3dc2efb66145365ddc17639ce81e', |
|
368 | '4fc55c43bf3d3dc2efb66145365ddc17639ce81e', | |
371 | ], changesets.collect(&:revision) |
|
369 | ], changesets.collect(&:revision) | |
372 |
|
370 | |||
373 | changesets = @repository.latest_changesets( |
|
371 | changesets = @repository.latest_changesets( | |
374 | "latin-1-dir/test-#{@char_1}-2.txt", '64f1f3e89', 1) |
|
372 | "latin-1-dir/test-#{@char_1}-2.txt", '64f1f3e89', 1) | |
375 | assert_equal [ |
|
373 | assert_equal [ | |
376 | '64f1f3e89ad1cb57976ff0ad99a107012ba3481d', |
|
374 | '64f1f3e89ad1cb57976ff0ad99a107012ba3481d', | |
377 | ], changesets.collect(&:revision) |
|
375 | ], changesets.collect(&:revision) | |
378 | end |
|
376 | end | |
379 | end |
|
377 | end | |
380 |
|
378 | |||
381 | def test_latest_changesets_latin_1_dir |
|
379 | def test_latest_changesets_latin_1_dir | |
382 | if WINDOWS_PASS |
|
380 | if WINDOWS_PASS | |
383 | # |
|
381 | # | |
384 | elsif JRUBY_SKIP |
|
382 | elsif JRUBY_SKIP | |
385 | puts JRUBY_SKIP_STR |
|
383 | puts JRUBY_SKIP_STR | |
386 | else |
|
384 | else | |
387 | assert_equal 0, @repository.changesets.count |
|
385 | assert_equal 0, @repository.changesets.count | |
388 | @repository.fetch_changesets |
|
386 | @repository.fetch_changesets | |
389 | @project.reload |
|
387 | @project.reload | |
390 | assert_equal NUM_REV, @repository.changesets.count |
|
388 | assert_equal NUM_REV, @repository.changesets.count | |
391 | changesets = @repository.latest_changesets( |
|
389 | changesets = @repository.latest_changesets( | |
392 | "latin-1-dir/test-#{@char_1}-subdir", '1ca7f5ed') |
|
390 | "latin-1-dir/test-#{@char_1}-subdir", '1ca7f5ed') | |
393 | assert_equal [ |
|
391 | assert_equal [ | |
394 | '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127', |
|
392 | '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127', | |
395 | ], changesets.collect(&:revision) |
|
393 | ], changesets.collect(&:revision) | |
396 | end |
|
394 | end | |
397 | end |
|
395 | end | |
398 |
|
396 | |||
399 | def test_find_changeset_by_name |
|
397 | def test_find_changeset_by_name | |
400 | assert_equal 0, @repository.changesets.count |
|
398 | assert_equal 0, @repository.changesets.count | |
401 | @repository.fetch_changesets |
|
399 | @repository.fetch_changesets | |
402 | @project.reload |
|
400 | @project.reload | |
403 | assert_equal NUM_REV, @repository.changesets.count |
|
401 | assert_equal NUM_REV, @repository.changesets.count | |
404 | ['7234cb2750b63f47bff735edc50a1c0a433c2518', '7234cb2750b'].each do |r| |
|
402 | ['7234cb2750b63f47bff735edc50a1c0a433c2518', '7234cb2750b'].each do |r| | |
405 | assert_equal '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
403 | assert_equal '7234cb2750b63f47bff735edc50a1c0a433c2518', | |
406 | @repository.find_changeset_by_name(r).revision |
|
404 | @repository.find_changeset_by_name(r).revision | |
407 | end |
|
405 | end | |
408 | end |
|
406 | end | |
409 |
|
407 | |||
410 | def test_find_changeset_by_empty_name |
|
408 | def test_find_changeset_by_empty_name | |
411 | assert_equal 0, @repository.changesets.count |
|
409 | assert_equal 0, @repository.changesets.count | |
412 | @repository.fetch_changesets |
|
410 | @repository.fetch_changesets | |
413 | @project.reload |
|
411 | @project.reload | |
414 | assert_equal NUM_REV, @repository.changesets.count |
|
412 | assert_equal NUM_REV, @repository.changesets.count | |
415 | ['', ' ', nil].each do |r| |
|
413 | ['', ' ', nil].each do |r| | |
416 | assert_nil @repository.find_changeset_by_name(r) |
|
414 | assert_nil @repository.find_changeset_by_name(r) | |
417 | end |
|
415 | end | |
418 | end |
|
416 | end | |
419 |
|
417 | |||
420 | def test_identifier |
|
418 | def test_identifier | |
421 | assert_equal 0, @repository.changesets.count |
|
419 | assert_equal 0, @repository.changesets.count | |
422 | @repository.fetch_changesets |
|
420 | @repository.fetch_changesets | |
423 | @project.reload |
|
421 | @project.reload | |
424 | assert_equal NUM_REV, @repository.changesets.count |
|
422 | assert_equal NUM_REV, @repository.changesets.count | |
425 | c = @repository.changesets.find_by_revision( |
|
423 | c = @repository.changesets.find_by_revision( | |
426 | '7234cb2750b63f47bff735edc50a1c0a433c2518') |
|
424 | '7234cb2750b63f47bff735edc50a1c0a433c2518') | |
427 | assert_equal c.scmid, c.identifier |
|
425 | assert_equal c.scmid, c.identifier | |
428 | end |
|
426 | end | |
429 |
|
427 | |||
430 | def test_format_identifier |
|
428 | def test_format_identifier | |
431 | assert_equal 0, @repository.changesets.count |
|
429 | assert_equal 0, @repository.changesets.count | |
432 | @repository.fetch_changesets |
|
430 | @repository.fetch_changesets | |
433 | @project.reload |
|
431 | @project.reload | |
434 | assert_equal NUM_REV, @repository.changesets.count |
|
432 | assert_equal NUM_REV, @repository.changesets.count | |
435 | c = @repository.changesets.find_by_revision( |
|
433 | c = @repository.changesets.find_by_revision( | |
436 | '7234cb2750b63f47bff735edc50a1c0a433c2518') |
|
434 | '7234cb2750b63f47bff735edc50a1c0a433c2518') | |
437 | assert_equal '7234cb27', c.format_identifier |
|
435 | assert_equal '7234cb27', c.format_identifier | |
438 | end |
|
436 | end | |
439 |
|
437 | |||
440 | def test_activities |
|
438 | def test_activities | |
441 | c = Changeset.new(:repository => @repository, |
|
439 | c = Changeset.new(:repository => @repository, | |
442 | :committed_on => Time.now, |
|
440 | :committed_on => Time.now, | |
443 | :revision => 'abc7234cb2750b63f47bff735edc50a1c0a433c2', |
|
441 | :revision => 'abc7234cb2750b63f47bff735edc50a1c0a433c2', | |
444 | :scmid => 'abc7234cb2750b63f47bff735edc50a1c0a433c2', |
|
442 | :scmid => 'abc7234cb2750b63f47bff735edc50a1c0a433c2', | |
445 | :comments => 'test') |
|
443 | :comments => 'test') | |
446 | assert c.event_title.include?('abc7234c:') |
|
444 | assert c.event_title.include?('abc7234c:') | |
447 | assert_equal 'abc7234cb2750b63f47bff735edc50a1c0a433c2', c.event_url[:rev] |
|
445 | assert_equal 'abc7234cb2750b63f47bff735edc50a1c0a433c2', c.event_url[:rev] | |
448 | end |
|
446 | end | |
449 |
|
447 | |||
450 | def test_log_utf8 |
|
448 | def test_log_utf8 | |
451 | assert_equal 0, @repository.changesets.count |
|
449 | assert_equal 0, @repository.changesets.count | |
452 | @repository.fetch_changesets |
|
450 | @repository.fetch_changesets | |
453 | @project.reload |
|
451 | @project.reload | |
454 | assert_equal NUM_REV, @repository.changesets.count |
|
452 | assert_equal NUM_REV, @repository.changesets.count | |
455 | str_felix_hex = FELIX_HEX.dup |
|
453 | str_felix_hex = FELIX_HEX.dup | |
456 | if str_felix_hex.respond_to?(:force_encoding) |
|
454 | if str_felix_hex.respond_to?(:force_encoding) | |
457 | str_felix_hex.force_encoding('UTF-8') |
|
455 | str_felix_hex.force_encoding('UTF-8') | |
458 | end |
|
456 | end | |
459 | c = @repository.changesets.find_by_revision( |
|
457 | c = @repository.changesets.find_by_revision( | |
460 | 'ed5bb786bbda2dee66a2d50faf51429dbc043a7b') |
|
458 | 'ed5bb786bbda2dee66a2d50faf51429dbc043a7b') | |
461 | assert_equal "#{str_felix_hex} <felix@fachschaften.org>", c.committer |
|
459 | assert_equal "#{str_felix_hex} <felix@fachschaften.org>", c.committer | |
462 | end |
|
460 | end | |
463 |
|
461 | |||
464 | def test_previous |
|
462 | def test_previous | |
465 | assert_equal 0, @repository.changesets.count |
|
463 | assert_equal 0, @repository.changesets.count | |
466 | @repository.fetch_changesets |
|
464 | @repository.fetch_changesets | |
467 | @project.reload |
|
465 | @project.reload | |
468 | assert_equal NUM_REV, @repository.changesets.count |
|
466 | assert_equal NUM_REV, @repository.changesets.count | |
469 | %w|1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127 1ca7f5ed|.each do |r1| |
|
467 | %w|1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127 1ca7f5ed|.each do |r1| | |
470 | changeset = @repository.find_changeset_by_name(r1) |
|
468 | changeset = @repository.find_changeset_by_name(r1) | |
471 | %w|64f1f3e89ad1cb57976ff0ad99a107012ba3481d 64f1f3e89ad1|.each do |r2| |
|
469 | %w|64f1f3e89ad1cb57976ff0ad99a107012ba3481d 64f1f3e89ad1|.each do |r2| | |
472 | assert_equal @repository.find_changeset_by_name(r2), changeset.previous |
|
470 | assert_equal @repository.find_changeset_by_name(r2), changeset.previous | |
473 | end |
|
471 | end | |
474 | end |
|
472 | end | |
475 | end |
|
473 | end | |
476 |
|
474 | |||
477 | def test_previous_nil |
|
475 | def test_previous_nil | |
478 | assert_equal 0, @repository.changesets.count |
|
476 | assert_equal 0, @repository.changesets.count | |
479 | @repository.fetch_changesets |
|
477 | @repository.fetch_changesets | |
480 | @project.reload |
|
478 | @project.reload | |
481 | assert_equal NUM_REV, @repository.changesets.count |
|
479 | assert_equal NUM_REV, @repository.changesets.count | |
482 | %w|7234cb2750b63f47bff735edc50a1c0a433c2518 7234cb2|.each do |r1| |
|
480 | %w|95488a44bc25f7d1f97d775a31359539ff333a63 95488a44b|.each do |r1| | |
483 | changeset = @repository.find_changeset_by_name(r1) |
|
481 | changeset = @repository.find_changeset_by_name(r1) | |
484 | assert_nil changeset.previous |
|
482 | assert_nil changeset.previous | |
485 | end |
|
483 | end | |
486 | end |
|
484 | end | |
487 |
|
485 | |||
488 | def test_next |
|
486 | def test_next | |
489 | assert_equal 0, @repository.changesets.count |
|
487 | assert_equal 0, @repository.changesets.count | |
490 | @repository.fetch_changesets |
|
488 | @repository.fetch_changesets | |
491 | @project.reload |
|
489 | @project.reload | |
492 | assert_equal NUM_REV, @repository.changesets.count |
|
490 | assert_equal NUM_REV, @repository.changesets.count | |
493 | %w|64f1f3e89ad1cb57976ff0ad99a107012ba3481d 64f1f3e89ad1|.each do |r2| |
|
491 | %w|64f1f3e89ad1cb57976ff0ad99a107012ba3481d 64f1f3e89ad1|.each do |r2| | |
494 | changeset = @repository.find_changeset_by_name(r2) |
|
492 | changeset = @repository.find_changeset_by_name(r2) | |
495 | %w|1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127 1ca7f5ed|.each do |r1| |
|
493 | %w|1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127 1ca7f5ed|.each do |r1| | |
496 | assert_equal @repository.find_changeset_by_name(r1), changeset.next |
|
494 | assert_equal @repository.find_changeset_by_name(r1), changeset.next | |
497 | end |
|
495 | end | |
498 | end |
|
496 | end | |
499 | end |
|
497 | end | |
500 |
|
498 | |||
501 | def test_next_nil |
|
499 | def test_next_nil | |
502 | assert_equal 0, @repository.changesets.count |
|
500 | assert_equal 0, @repository.changesets.count | |
503 | @repository.fetch_changesets |
|
501 | @repository.fetch_changesets | |
504 | @project.reload |
|
502 | @project.reload | |
505 | assert_equal NUM_REV, @repository.changesets.count |
|
503 | assert_equal NUM_REV, @repository.changesets.count | |
506 | %w|67e7792ce20ccae2e4bb73eed09bb397819c8834 67e7792ce20cca|.each do |r1| |
|
504 | %w|67e7792ce20ccae2e4bb73eed09bb397819c8834 67e7792ce20cca|.each do |r1| | |
507 | changeset = @repository.find_changeset_by_name(r1) |
|
505 | changeset = @repository.find_changeset_by_name(r1) | |
508 | assert_nil changeset.next |
|
506 | assert_nil changeset.next | |
509 | end |
|
507 | end | |
510 | end |
|
508 | end | |
511 | else |
|
509 | else | |
512 | puts "Git test repository NOT FOUND. Skipping unit tests !!!" |
|
510 | puts "Git test repository NOT FOUND. Skipping unit tests !!!" | |
513 | def test_fake; assert true end |
|
511 | def test_fake; assert true end | |
514 | end |
|
512 | end | |
515 | end |
|
513 | end |
General Comments 0
You need to be logged in to leave comments.
Login now