Mercurial > hg > soundsoftware-site
comparison test/functional/repositories_git_controller_test.rb @ 909:cbb26bc654de redmine-1.3
Update to Redmine 1.3-stable branch (Redmine SVN rev 8964)
author | Chris Cannam |
---|---|
date | Fri, 24 Feb 2012 19:09:32 +0000 |
parents | 0c939c159af4 |
children | 433d4f72a19b |
comparison
equal
deleted
inserted
replaced
908:c6c2cbd0afee | 909:cbb26bc654de |
---|---|
20 | 20 |
21 # Re-raise errors caught by the controller. | 21 # Re-raise errors caught by the controller. |
22 class RepositoriesController; def rescue_action(e) raise e end; end | 22 class RepositoriesController; def rescue_action(e) raise e end; end |
23 | 23 |
24 class RepositoriesGitControllerTest < ActionController::TestCase | 24 class RepositoriesGitControllerTest < ActionController::TestCase |
25 fixtures :projects, :users, :roles, :members, :member_roles, :repositories, :enabled_modules | 25 fixtures :projects, :users, :roles, :members, :member_roles, |
26 | 26 :repositories, :enabled_modules |
27 # No '..' in the repository path | 27 |
28 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/git_repository' | 28 REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s |
29 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin? | 29 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin? |
30 PRJ_ID = 3 | 30 PRJ_ID = 3 |
31 CHAR_1_HEX = "\xc3\x9c" | 31 CHAR_1_HEX = "\xc3\x9c" |
32 NUM_REV = 21 | |
33 | |
34 ## Git, Mercurial and CVS path encodings are binary. | |
35 ## Subversion supports URL encoding for path. | |
36 ## Redmine Mercurial adapter and extension use URL encoding. | |
37 ## Git accepts only binary path in command line parameter. | |
38 ## So, there is no way to use binary command line parameter in JRuby. | |
39 JRUBY_SKIP = (RUBY_PLATFORM == 'java') | |
40 JRUBY_SKIP_STR = "TODO: This test fails in JRuby" | |
32 | 41 |
33 def setup | 42 def setup |
34 @ruby19_non_utf8_pass = | 43 @ruby19_non_utf8_pass = |
35 (RUBY_VERSION >= '1.9' && Encoding.default_external.to_s != 'UTF-8') | 44 (RUBY_VERSION >= '1.9' && Encoding.default_external.to_s != 'UTF-8') |
36 | 45 |
37 @controller = RepositoriesController.new | 46 @controller = RepositoriesController.new |
38 @request = ActionController::TestRequest.new | 47 @request = ActionController::TestRequest.new |
39 @response = ActionController::TestResponse.new | 48 @response = ActionController::TestResponse.new |
40 User.current = nil | 49 User.current = nil |
50 @project = Project.find(PRJ_ID) | |
41 @repository = Repository::Git.create( | 51 @repository = Repository::Git.create( |
42 :project => Project.find(3), | 52 :project => @project, |
43 :url => REPOSITORY_PATH, | 53 :url => REPOSITORY_PATH, |
44 :path_encoding => 'ISO-8859-1' | 54 :path_encoding => 'ISO-8859-1' |
45 ) | 55 ) |
46 assert @repository | 56 assert @repository |
47 @char_1 = CHAR_1_HEX.dup | 57 @char_1 = CHAR_1_HEX.dup |
48 if @char_1.respond_to?(:force_encoding) | 58 if @char_1.respond_to?(:force_encoding) |
52 Setting.default_language = 'en' | 62 Setting.default_language = 'en' |
53 end | 63 end |
54 | 64 |
55 if File.directory?(REPOSITORY_PATH) | 65 if File.directory?(REPOSITORY_PATH) |
56 def test_browse_root | 66 def test_browse_root |
57 @repository.fetch_changesets | 67 assert_equal 0, @repository.changesets.count |
58 @repository.reload | 68 @repository.fetch_changesets |
69 @project.reload | |
70 assert_equal NUM_REV, @repository.changesets.count | |
71 | |
59 get :show, :id => PRJ_ID | 72 get :show, :id => PRJ_ID |
60 assert_response :success | 73 assert_response :success |
61 assert_template 'show' | 74 assert_template 'show' |
62 assert_not_nil assigns(:entries) | 75 assert_not_nil assigns(:entries) |
63 assert_equal 9, assigns(:entries).size | 76 assert_equal 9, assigns(:entries).size |
69 assert assigns(:entries).detect {|e| e.name == 'new_file.txt' && e.kind == 'file'} | 82 assert assigns(:entries).detect {|e| e.name == 'new_file.txt' && e.kind == 'file'} |
70 assert assigns(:entries).detect {|e| e.name == 'renamed_test.txt' && e.kind == 'file'} | 83 assert assigns(:entries).detect {|e| e.name == 'renamed_test.txt' && e.kind == 'file'} |
71 assert assigns(:entries).detect {|e| e.name == 'filemane with spaces.txt' && e.kind == 'file'} | 84 assert assigns(:entries).detect {|e| e.name == 'filemane with spaces.txt' && e.kind == 'file'} |
72 assert assigns(:entries).detect {|e| e.name == ' filename with a leading space.txt ' && e.kind == 'file'} | 85 assert assigns(:entries).detect {|e| e.name == ' filename with a leading space.txt ' && e.kind == 'file'} |
73 assert_not_nil assigns(:changesets) | 86 assert_not_nil assigns(:changesets) |
74 assigns(:changesets).size > 0 | 87 assert assigns(:changesets).size > 0 |
75 end | 88 end |
76 | 89 |
77 def test_browse_branch | 90 def test_browse_branch |
78 @repository.fetch_changesets | 91 assert_equal 0, @repository.changesets.count |
79 @repository.reload | 92 @repository.fetch_changesets |
93 @project.reload | |
94 assert_equal NUM_REV, @repository.changesets.count | |
80 get :show, :id => PRJ_ID, :rev => 'test_branch' | 95 get :show, :id => PRJ_ID, :rev => 'test_branch' |
81 assert_response :success | 96 assert_response :success |
82 assert_template 'show' | 97 assert_template 'show' |
83 assert_not_nil assigns(:entries) | 98 assert_not_nil assigns(:entries) |
84 assert_equal 4, assigns(:entries).size | 99 assert_equal 4, assigns(:entries).size |
85 assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'} | 100 assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'} |
86 assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'} | 101 assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'} |
87 assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'} | 102 assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'} |
88 assert assigns(:entries).detect {|e| e.name == 'test.txt' && e.kind == 'file'} | 103 assert assigns(:entries).detect {|e| e.name == 'test.txt' && e.kind == 'file'} |
89 assert_not_nil assigns(:changesets) | 104 assert_not_nil assigns(:changesets) |
90 assigns(:changesets).size > 0 | 105 assert assigns(:changesets).size > 0 |
91 end | 106 end |
92 | 107 |
93 def test_browse_tag | 108 def test_browse_tag |
94 @repository.fetch_changesets | 109 assert_equal 0, @repository.changesets.count |
95 @repository.reload | 110 @repository.fetch_changesets |
111 @project.reload | |
112 assert_equal NUM_REV, @repository.changesets.count | |
96 [ | 113 [ |
97 "tag00.lightweight", | 114 "tag00.lightweight", |
98 "tag01.annotated", | 115 "tag01.annotated", |
99 ].each do |t1| | 116 ].each do |t1| |
100 get :show, :id => PRJ_ID, :rev => t1 | 117 get :show, :id => PRJ_ID, :rev => t1 |
101 assert_response :success | 118 assert_response :success |
102 assert_template 'show' | 119 assert_template 'show' |
103 assert_not_nil assigns(:entries) | 120 assert_not_nil assigns(:entries) |
104 assigns(:entries).size > 0 | 121 assert assigns(:entries).size > 0 |
105 assert_not_nil assigns(:changesets) | 122 assert_not_nil assigns(:changesets) |
106 assigns(:changesets).size > 0 | 123 assert assigns(:changesets).size > 0 |
107 end | 124 end |
108 end | 125 end |
109 | 126 |
110 def test_browse_directory | 127 def test_browse_directory |
111 @repository.fetch_changesets | 128 assert_equal 0, @repository.changesets.count |
112 @repository.reload | 129 @repository.fetch_changesets |
130 @project.reload | |
131 assert_equal NUM_REV, @repository.changesets.count | |
113 get :show, :id => PRJ_ID, :path => ['images'] | 132 get :show, :id => PRJ_ID, :path => ['images'] |
114 assert_response :success | 133 assert_response :success |
115 assert_template 'show' | 134 assert_template 'show' |
116 assert_not_nil assigns(:entries) | 135 assert_not_nil assigns(:entries) |
117 assert_equal ['edit.png'], assigns(:entries).collect(&:name) | 136 assert_equal ['edit.png'], assigns(:entries).collect(&:name) |
118 entry = assigns(:entries).detect {|e| e.name == 'edit.png'} | 137 entry = assigns(:entries).detect {|e| e.name == 'edit.png'} |
119 assert_not_nil entry | 138 assert_not_nil entry |
120 assert_equal 'file', entry.kind | 139 assert_equal 'file', entry.kind |
121 assert_equal 'images/edit.png', entry.path | 140 assert_equal 'images/edit.png', entry.path |
122 assert_not_nil assigns(:changesets) | 141 assert_not_nil assigns(:changesets) |
123 assigns(:changesets).size > 0 | 142 assert assigns(:changesets).size > 0 |
124 end | 143 end |
125 | 144 |
126 def test_browse_at_given_revision | 145 def test_browse_at_given_revision |
127 @repository.fetch_changesets | 146 assert_equal 0, @repository.changesets.count |
128 @repository.reload | 147 @repository.fetch_changesets |
148 @project.reload | |
149 assert_equal NUM_REV, @repository.changesets.count | |
129 get :show, :id => PRJ_ID, :path => ['images'], | 150 get :show, :id => PRJ_ID, :path => ['images'], |
130 :rev => '7234cb2750b63f47bff735edc50a1c0a433c2518' | 151 :rev => '7234cb2750b63f47bff735edc50a1c0a433c2518' |
131 assert_response :success | 152 assert_response :success |
132 assert_template 'show' | 153 assert_template 'show' |
133 assert_not_nil assigns(:entries) | 154 assert_not_nil assigns(:entries) |
134 assert_equal ['delete.png'], assigns(:entries).collect(&:name) | 155 assert_equal ['delete.png'], assigns(:entries).collect(&:name) |
135 assert_not_nil assigns(:changesets) | 156 assert_not_nil assigns(:changesets) |
136 assigns(:changesets).size > 0 | 157 assert assigns(:changesets).size > 0 |
137 end | 158 end |
138 | 159 |
139 def test_changes | 160 def test_changes |
140 get :changes, :id => PRJ_ID, :path => ['images', 'edit.png'] | 161 get :changes, :id => PRJ_ID, :path => ['images', 'edit.png'] |
141 assert_response :success | 162 assert_response :success |
155 end | 176 end |
156 | 177 |
157 def test_entry_show_latin_1 | 178 def test_entry_show_latin_1 |
158 if @ruby19_non_utf8_pass | 179 if @ruby19_non_utf8_pass |
159 puts_ruby19_non_utf8_pass() | 180 puts_ruby19_non_utf8_pass() |
181 elsif JRUBY_SKIP | |
182 puts JRUBY_SKIP_STR | |
160 else | 183 else |
161 with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do | 184 with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do |
162 ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1| | 185 ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1| |
163 get :entry, :id => PRJ_ID, | 186 get :entry, :id => PRJ_ID, |
164 :path => ['latin-1-dir', "test-#{@char_1}.txt"], :rev => r1 | 187 :path => ['latin-1-dir', "test-#{@char_1}.txt"], :rev => r1 |
189 assert_not_nil assigns(:entry) | 212 assert_not_nil assigns(:entry) |
190 assert_equal 'sources', assigns(:entry).name | 213 assert_equal 'sources', assigns(:entry).name |
191 end | 214 end |
192 | 215 |
193 def test_diff | 216 def test_diff |
194 @repository.fetch_changesets | 217 assert_equal 0, @repository.changesets.count |
195 @repository.reload | 218 @repository.fetch_changesets |
219 @project.reload | |
220 assert_equal NUM_REV, @repository.changesets.count | |
196 # Full diff of changeset 2f9c0091 | 221 # Full diff of changeset 2f9c0091 |
197 get :diff, :id => PRJ_ID, :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' | 222 ['inline', 'sbs'].each do |dt| |
198 assert_response :success | 223 get :diff, |
199 assert_template 'diff' | 224 :id => PRJ_ID, |
200 # Line 22 removed | 225 :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7', |
201 assert_tag :tag => 'th', | 226 :type => dt |
202 :content => /22/, | 227 assert_response :success |
203 :sibling => { :tag => 'td', | 228 assert_template 'diff' |
204 :attributes => { :class => /diff_out/ }, | 229 # Line 22 removed |
205 :content => /def remove/ } | 230 assert_tag :tag => 'th', |
206 assert_tag :tag => 'h2', :content => /2f9c0091/ | 231 :content => /22/, |
232 :sibling => { :tag => 'td', | |
233 :attributes => { :class => /diff_out/ }, | |
234 :content => /def remove/ } | |
235 assert_tag :tag => 'h2', :content => /2f9c0091/ | |
236 end | |
207 end | 237 end |
208 | 238 |
209 def test_diff_truncated | 239 def test_diff_truncated |
210 @repository.fetch_changesets | 240 assert_equal 0, @repository.changesets.count |
211 @repository.reload | 241 @repository.fetch_changesets |
242 @project.reload | |
243 assert_equal NUM_REV, @repository.changesets.count | |
212 Setting.diff_max_lines_displayed = 5 | 244 Setting.diff_max_lines_displayed = 5 |
213 | 245 |
214 # Truncated diff of changeset 2f9c0091 | 246 # Truncated diff of changeset 2f9c0091 |
215 with_cache do | 247 with_cache do |
216 get :diff, :id => PRJ_ID, :type => 'inline', | 248 get :diff, :id => PRJ_ID, :type => 'inline', |
226 assert @response.body.include?("... Ce diff") | 258 assert @response.body.include?("... Ce diff") |
227 end | 259 end |
228 end | 260 end |
229 | 261 |
230 def test_diff_two_revs | 262 def test_diff_two_revs |
231 @repository.fetch_changesets | 263 assert_equal 0, @repository.changesets.count |
232 @repository.reload | 264 @repository.fetch_changesets |
233 get :diff, :id => PRJ_ID, | 265 @project.reload |
234 :rev => '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', | 266 assert_equal NUM_REV, @repository.changesets.count |
235 :rev_to => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' | 267 ['inline', 'sbs'].each do |dt| |
236 assert_response :success | 268 get :diff, |
237 assert_template 'diff' | 269 :id => PRJ_ID, |
238 diff = assigns(:diff) | 270 :rev => '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', |
239 assert_not_nil diff | 271 :rev_to => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7', |
240 assert_tag :tag => 'h2', :content => /2f9c0091:61b685fb/ | 272 :type => dt |
273 assert_response :success | |
274 assert_template 'diff' | |
275 diff = assigns(:diff) | |
276 assert_not_nil diff | |
277 assert_tag :tag => 'h2', :content => /2f9c0091:61b685fb/ | |
278 end | |
241 end | 279 end |
242 | 280 |
243 def test_diff_latin_1 | 281 def test_diff_latin_1 |
244 if @ruby19_non_utf8_pass | 282 if @ruby19_non_utf8_pass |
245 puts_ruby19_non_utf8_pass() | 283 puts_ruby19_non_utf8_pass() |
246 else | 284 else |
247 with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do | 285 with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do |
248 ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1| | 286 ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1| |
249 get :diff, :id => PRJ_ID, :rev => r1 | 287 ['inline', 'sbs'].each do |dt| |
250 assert_response :success | 288 get :diff, :id => PRJ_ID, :rev => r1, :type => dt |
251 assert_template 'diff' | 289 assert_response :success |
252 assert_tag :tag => 'thead', | 290 assert_template 'diff' |
253 :descendant => { | 291 assert_tag :tag => 'thead', |
254 :tag => 'th', | |
255 :attributes => { :class => 'filename' } , | |
256 :content => /latin-1-dir\/test-#{@char_1}.txt/ , | |
257 }, | |
258 :sibling => { | |
259 :tag => 'tbody', | |
260 :descendant => { | 292 :descendant => { |
261 :tag => 'td', | 293 :tag => 'th', |
262 :attributes => { :class => /diff_in/ }, | 294 :attributes => { :class => 'filename' } , |
263 :content => /test-#{@char_1}.txt/ | 295 :content => /latin-1-dir\/test-#{@char_1}.txt/ , |
296 }, | |
297 :sibling => { | |
298 :tag => 'tbody', | |
299 :descendant => { | |
300 :tag => 'td', | |
301 :attributes => { :class => /diff_in/ }, | |
302 :content => /test-#{@char_1}.txt/ | |
303 } | |
264 } | 304 } |
265 } | 305 end |
266 end | 306 end |
267 end | 307 end |
268 end | 308 end |
269 end | 309 end |
270 | 310 |
311 def test_save_diff_type | |
312 @request.session[:user_id] = 1 # admin | |
313 user = User.find(1) | |
314 get :diff, | |
315 :id => PRJ_ID, | |
316 :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' | |
317 assert_response :success | |
318 assert_template 'diff' | |
319 user.reload | |
320 assert_equal "inline", user.pref[:diff_type] | |
321 get :diff, | |
322 :id => PRJ_ID, | |
323 :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7', | |
324 :type => 'sbs' | |
325 assert_response :success | |
326 assert_template 'diff' | |
327 user.reload | |
328 assert_equal "sbs", user.pref[:diff_type] | |
329 end | |
330 | |
271 def test_annotate | 331 def test_annotate |
272 get :annotate, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'] | 332 get :annotate, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'] |
273 assert_response :success | 333 assert_response :success |
274 assert_template 'annotate' | 334 assert_template 'annotate' |
275 # Line 23, changeset 2f9c0091 | 335 # Line 24, changeset 2f9c0091 |
276 assert_tag :tag => 'th', :content => '24', | 336 assert_tag :tag => 'th', :content => '24', |
277 :sibling => { | 337 :sibling => { |
278 :tag => 'td', | 338 :tag => 'td', |
279 :child => { | 339 :child => { |
280 :tag => 'a', | 340 :tag => 'a', |
281 :content => /2f9c0091c754a91af7a9c478e36556b4bde8dcf7/ | 341 :content => /2f9c0091/ |
282 } | 342 } |
283 }, | 343 } |
344 assert_tag :tag => 'th', :content => '24', | |
284 :sibling => { :tag => 'td', :content => /jsmith/ } | 345 :sibling => { :tag => 'td', :content => /jsmith/ } |
285 assert_tag :tag => 'th', :content => '24', | 346 assert_tag :tag => 'th', :content => '24', |
286 :sibling => { | 347 :sibling => { |
287 :tag => 'td', | 348 :tag => 'td', |
288 :child => { | 349 :child => { |
289 :tag => 'a', | 350 :tag => 'a', |
290 :content => /2f9c0091c754a91af7a9c478e36556b4bde8dcf7/ | 351 :content => /2f9c0091/ |
291 } | 352 } |
292 }, | 353 } |
354 assert_tag :tag => 'th', :content => '24', | |
293 :sibling => { :tag => 'td', :content => /watcher =/ } | 355 :sibling => { :tag => 'td', :content => /watcher =/ } |
294 end | 356 end |
295 | 357 |
296 def test_annotate_at_given_revision | 358 def test_annotate_at_given_revision |
297 @repository.fetch_changesets | 359 assert_equal 0, @repository.changesets.count |
298 @repository.reload | 360 @repository.fetch_changesets |
361 @project.reload | |
362 assert_equal NUM_REV, @repository.changesets.count | |
299 get :annotate, :id => PRJ_ID, :rev => 'deff7', | 363 get :annotate, :id => PRJ_ID, :rev => 'deff7', |
300 :path => ['sources', 'watchers_controller.rb'] | 364 :path => ['sources', 'watchers_controller.rb'] |
301 assert_response :success | 365 assert_response :success |
302 assert_template 'annotate' | 366 assert_template 'annotate' |
303 assert_tag :tag => 'h2', :content => /@ deff712f/ | 367 assert_tag :tag => 'h2', :content => /@ deff712f/ |
308 assert_response 500 | 372 assert_response 500 |
309 assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, | 373 assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, |
310 :content => /cannot be annotated/ | 374 :content => /cannot be annotated/ |
311 end | 375 end |
312 | 376 |
377 def test_annotate_error_when_too_big | |
378 with_settings :file_max_size_displayed => 1 do | |
379 get :annotate, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'], :rev => 'deff712f' | |
380 assert_response 500 | |
381 assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, | |
382 :content => /exceeds the maximum text file size/ | |
383 | |
384 get :annotate, :id => PRJ_ID, :path => ['README'], :rev => '7234cb2' | |
385 assert_response :success | |
386 assert_template 'annotate' | |
387 end | |
388 end | |
389 | |
313 def test_annotate_latin_1 | 390 def test_annotate_latin_1 |
314 if @ruby19_non_utf8_pass | 391 if @ruby19_non_utf8_pass |
315 puts_ruby19_non_utf8_pass() | 392 puts_ruby19_non_utf8_pass() |
393 elsif JRUBY_SKIP | |
394 puts JRUBY_SKIP_STR | |
316 else | 395 else |
317 with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do | 396 with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do |
318 ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1| | 397 ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1| |
319 get :annotate, :id => PRJ_ID, | 398 get :annotate, :id => PRJ_ID, |
320 :path => ['latin-1-dir', "test-#{@char_1}.txt"], :rev => r1 | 399 :path => ['latin-1-dir', "test-#{@char_1}.txt"], :rev => r1 |
327 end | 406 end |
328 end | 407 end |
329 end | 408 end |
330 | 409 |
331 def test_revision | 410 def test_revision |
332 @repository.fetch_changesets | 411 assert_equal 0, @repository.changesets.count |
333 @repository.reload | 412 @repository.fetch_changesets |
413 @project.reload | |
414 assert_equal NUM_REV, @repository.changesets.count | |
334 ['61b685fbe55ab05b5ac68402d5720c1a6ac973d1', '61b685f'].each do |r| | 415 ['61b685fbe55ab05b5ac68402d5720c1a6ac973d1', '61b685f'].each do |r| |
335 get :revision, :id => PRJ_ID, :rev => r | 416 get :revision, :id => PRJ_ID, :rev => r |
336 assert_response :success | 417 assert_response :success |
337 assert_template 'revision' | 418 assert_template 'revision' |
338 end | 419 end |
339 end | 420 end |
340 | 421 |
341 def test_empty_revision | 422 def test_empty_revision |
342 @repository.fetch_changesets | 423 assert_equal 0, @repository.changesets.count |
343 @repository.reload | 424 @repository.fetch_changesets |
425 @project.reload | |
426 assert_equal NUM_REV, @repository.changesets.count | |
344 ['', ' ', nil].each do |r| | 427 ['', ' ', nil].each do |r| |
345 get :revision, :id => PRJ_ID, :rev => r | 428 get :revision, :id => PRJ_ID, :rev => r |
346 assert_response 404 | 429 assert_response 404 |
347 assert_error_tag :content => /was not found/ | 430 assert_error_tag :content => /was not found/ |
348 end | 431 end |
432 end | |
433 | |
434 def test_destroy_valid_repository | |
435 @request.session[:user_id] = 1 # admin | |
436 assert_equal 0, @repository.changesets.count | |
437 @repository.fetch_changesets | |
438 @project.reload | |
439 assert_equal NUM_REV, @repository.changesets.count | |
440 | |
441 get :destroy, :id => PRJ_ID | |
442 assert_response 302 | |
443 @project.reload | |
444 assert_nil @project.repository | |
445 end | |
446 | |
447 def test_destroy_invalid_repository | |
448 @request.session[:user_id] = 1 # admin | |
449 assert_equal 0, @repository.changesets.count | |
450 @repository.fetch_changesets | |
451 @project.reload | |
452 assert_equal NUM_REV, @repository.changesets.count | |
453 | |
454 get :destroy, :id => PRJ_ID | |
455 assert_response 302 | |
456 @project.reload | |
457 assert_nil @project.repository | |
458 | |
459 @repository = Repository::Git.create( | |
460 :project => @project, | |
461 :url => "/invalid", | |
462 :path_encoding => 'ISO-8859-1' | |
463 ) | |
464 assert @repository | |
465 @repository.fetch_changesets | |
466 @repository.reload | |
467 assert_equal 0, @repository.changesets.count | |
468 | |
469 get :destroy, :id => PRJ_ID | |
470 assert_response 302 | |
471 @project.reload | |
472 assert_nil @project.repository | |
349 end | 473 end |
350 | 474 |
351 private | 475 private |
352 | 476 |
353 def puts_ruby19_non_utf8_pass | 477 def puts_ruby19_non_utf8_pass |