Mercurial > hg > soundsoftware-site
comparison .svn/pristine/fe/fe2f213c294fbfcf1b3100eeeb0711ec3671f9df.svn-base @ 1517:dffacf8a6908 redmine-2.5
Update to Redmine SVN revision 13367 on 2.5-stable branch
author | Chris Cannam |
---|---|
date | Tue, 09 Sep 2014 09:29:00 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1516:b450a9d58aed | 1517:dffacf8a6908 |
---|---|
1 # Redmine - project management software | |
2 # Copyright (C) 2006-2014 Jean-Philippe Lang | |
3 # | |
4 # This program is free software; you can redistribute it and/or | |
5 # modify it under the terms of the GNU General Public License | |
6 # as published by the Free Software Foundation; either version 2 | |
7 # of the License, or (at your option) any later version. | |
8 # | |
9 # This program is distributed in the hope that it will be useful, | |
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 # GNU General Public License for more details. | |
13 # | |
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 | |
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 | |
18 require File.expand_path('../../test_helper', __FILE__) | |
19 | |
20 class RepositoriesGitControllerTest < ActionController::TestCase | |
21 tests RepositoriesController | |
22 | |
23 fixtures :projects, :users, :roles, :members, :member_roles, | |
24 :repositories, :enabled_modules | |
25 | |
26 REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s | |
27 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin? | |
28 PRJ_ID = 3 | |
29 CHAR_1_HEX = "\xc3\x9c" | |
30 FELIX_HEX = "Felix Sch\xC3\xA4fer" | |
31 NUM_REV = 28 | |
32 | |
33 ## Git, Mercurial and CVS path encodings are binary. | |
34 ## Subversion supports URL encoding for path. | |
35 ## Redmine Mercurial adapter and extension use URL encoding. | |
36 ## Git accepts only binary path in command line parameter. | |
37 ## So, there is no way to use binary command line parameter in JRuby. | |
38 JRUBY_SKIP = (RUBY_PLATFORM == 'java') | |
39 JRUBY_SKIP_STR = "TODO: This test fails in JRuby" | |
40 | |
41 def setup | |
42 @ruby19_non_utf8_pass = | |
43 (RUBY_VERSION >= '1.9' && Encoding.default_external.to_s != 'UTF-8') | |
44 | |
45 User.current = nil | |
46 @project = Project.find(PRJ_ID) | |
47 @repository = Repository::Git.create( | |
48 :project => @project, | |
49 :url => REPOSITORY_PATH, | |
50 :path_encoding => 'ISO-8859-1' | |
51 ) | |
52 assert @repository | |
53 @char_1 = CHAR_1_HEX.dup | |
54 @felix_utf8 = FELIX_HEX.dup | |
55 if @char_1.respond_to?(:force_encoding) | |
56 @char_1.force_encoding('UTF-8') | |
57 @felix_utf8.force_encoding('UTF-8') | |
58 end | |
59 end | |
60 | |
61 def test_create_and_update | |
62 @request.session[:user_id] = 1 | |
63 assert_difference 'Repository.count' do | |
64 post :create, :project_id => 'subproject1', | |
65 :repository_scm => 'Git', | |
66 :repository => { | |
67 :url => '/test', | |
68 :is_default => '0', | |
69 :identifier => 'test-create', | |
70 :extra_report_last_commit => '1', | |
71 } | |
72 end | |
73 assert_response 302 | |
74 repository = Repository.order('id DESC').first | |
75 assert_kind_of Repository::Git, repository | |
76 assert_equal '/test', repository.url | |
77 assert_equal true, repository.extra_report_last_commit | |
78 | |
79 put :update, :id => repository.id, | |
80 :repository => { | |
81 :extra_report_last_commit => '0' | |
82 } | |
83 assert_response 302 | |
84 repo2 = Repository.find(repository.id) | |
85 assert_equal false, repo2.extra_report_last_commit | |
86 end | |
87 | |
88 if File.directory?(REPOSITORY_PATH) | |
89 ## Ruby uses ANSI api to fork a process on Windows. | |
90 ## Japanese Shift_JIS and Traditional Chinese Big5 have 0x5c(backslash) problem | |
91 ## and these are incompatible with ASCII. | |
92 ## Git for Windows (msysGit) changed internal API from ANSI to Unicode in 1.7.10 | |
93 ## http://code.google.com/p/msysgit/issues/detail?id=80 | |
94 ## So, Latin-1 path tests fail on Japanese Windows | |
95 WINDOWS_PASS = (Redmine::Platform.mswin? && | |
96 Redmine::Scm::Adapters::GitAdapter.client_version_above?([1, 7, 10])) | |
97 WINDOWS_SKIP_STR = "TODO: This test fails in Git for Windows above 1.7.10" | |
98 | |
99 def test_get_new | |
100 @request.session[:user_id] = 1 | |
101 @project.repository.destroy | |
102 get :new, :project_id => 'subproject1', :repository_scm => 'Git' | |
103 assert_response :success | |
104 assert_template 'new' | |
105 assert_kind_of Repository::Git, assigns(:repository) | |
106 assert assigns(:repository).new_record? | |
107 end | |
108 | |
109 def test_browse_root | |
110 assert_equal 0, @repository.changesets.count | |
111 @repository.fetch_changesets | |
112 @project.reload | |
113 assert_equal NUM_REV, @repository.changesets.count | |
114 | |
115 get :show, :id => PRJ_ID | |
116 assert_response :success | |
117 assert_template 'show' | |
118 assert_not_nil assigns(:entries) | |
119 assert_equal 9, assigns(:entries).size | |
120 assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'} | |
121 assert assigns(:entries).detect {|e| e.name == 'this_is_a_really_long_and_verbose_directory_name' && e.kind == 'dir'} | |
122 assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'} | |
123 assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'} | |
124 assert assigns(:entries).detect {|e| e.name == 'copied_README' && e.kind == 'file'} | |
125 assert assigns(:entries).detect {|e| e.name == 'new_file.txt' && e.kind == 'file'} | |
126 assert assigns(:entries).detect {|e| e.name == 'renamed_test.txt' && e.kind == 'file'} | |
127 assert assigns(:entries).detect {|e| e.name == 'filemane with spaces.txt' && e.kind == 'file'} | |
128 assert assigns(:entries).detect {|e| e.name == ' filename with a leading space.txt ' && e.kind == 'file'} | |
129 assert_not_nil assigns(:changesets) | |
130 assert assigns(:changesets).size > 0 | |
131 end | |
132 | |
133 def test_browse_branch | |
134 assert_equal 0, @repository.changesets.count | |
135 @repository.fetch_changesets | |
136 @project.reload | |
137 assert_equal NUM_REV, @repository.changesets.count | |
138 get :show, :id => PRJ_ID, :rev => 'test_branch' | |
139 assert_response :success | |
140 assert_template 'show' | |
141 assert_not_nil assigns(:entries) | |
142 assert_equal 4, assigns(:entries).size | |
143 assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'} | |
144 assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'} | |
145 assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'} | |
146 assert assigns(:entries).detect {|e| e.name == 'test.txt' && e.kind == 'file'} | |
147 assert_not_nil assigns(:changesets) | |
148 assert assigns(:changesets).size > 0 | |
149 end | |
150 | |
151 def test_browse_tag | |
152 assert_equal 0, @repository.changesets.count | |
153 @repository.fetch_changesets | |
154 @project.reload | |
155 assert_equal NUM_REV, @repository.changesets.count | |
156 [ | |
157 "tag00.lightweight", | |
158 "tag01.annotated", | |
159 ].each do |t1| | |
160 get :show, :id => PRJ_ID, :rev => t1 | |
161 assert_response :success | |
162 assert_template 'show' | |
163 assert_not_nil assigns(:entries) | |
164 assert assigns(:entries).size > 0 | |
165 assert_not_nil assigns(:changesets) | |
166 assert assigns(:changesets).size > 0 | |
167 end | |
168 end | |
169 | |
170 def test_browse_directory | |
171 assert_equal 0, @repository.changesets.count | |
172 @repository.fetch_changesets | |
173 @project.reload | |
174 assert_equal NUM_REV, @repository.changesets.count | |
175 get :show, :id => PRJ_ID, :path => repository_path_hash(['images'])[:param] | |
176 assert_response :success | |
177 assert_template 'show' | |
178 assert_not_nil assigns(:entries) | |
179 assert_equal ['edit.png'], assigns(:entries).collect(&:name) | |
180 entry = assigns(:entries).detect {|e| e.name == 'edit.png'} | |
181 assert_not_nil entry | |
182 assert_equal 'file', entry.kind | |
183 assert_equal 'images/edit.png', entry.path | |
184 assert_not_nil assigns(:changesets) | |
185 assert assigns(:changesets).size > 0 | |
186 end | |
187 | |
188 def test_browse_at_given_revision | |
189 assert_equal 0, @repository.changesets.count | |
190 @repository.fetch_changesets | |
191 @project.reload | |
192 assert_equal NUM_REV, @repository.changesets.count | |
193 get :show, :id => PRJ_ID, :path => repository_path_hash(['images'])[:param], | |
194 :rev => '7234cb2750b63f47bff735edc50a1c0a433c2518' | |
195 assert_response :success | |
196 assert_template 'show' | |
197 assert_not_nil assigns(:entries) | |
198 assert_equal ['delete.png'], assigns(:entries).collect(&:name) | |
199 assert_not_nil assigns(:changesets) | |
200 assert assigns(:changesets).size > 0 | |
201 end | |
202 | |
203 def test_changes | |
204 get :changes, :id => PRJ_ID, | |
205 :path => repository_path_hash(['images', 'edit.png'])[:param] | |
206 assert_response :success | |
207 assert_template 'changes' | |
208 assert_tag :tag => 'h2', :content => 'edit.png' | |
209 end | |
210 | |
211 def test_entry_show | |
212 get :entry, :id => PRJ_ID, | |
213 :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param] | |
214 assert_response :success | |
215 assert_template 'entry' | |
216 # Line 19 | |
217 assert_tag :tag => 'th', | |
218 :content => '11', | |
219 :attributes => { :class => 'line-num' }, | |
220 :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ } | |
221 end | |
222 | |
223 def test_entry_show_latin_1 | |
224 if @ruby19_non_utf8_pass | |
225 puts_ruby19_non_utf8_pass() | |
226 elsif WINDOWS_PASS | |
227 puts WINDOWS_SKIP_STR | |
228 elsif JRUBY_SKIP | |
229 puts JRUBY_SKIP_STR | |
230 else | |
231 with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do | |
232 ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1| | |
233 get :entry, :id => PRJ_ID, | |
234 :path => repository_path_hash(['latin-1-dir', "test-#{@char_1}.txt"])[:param], | |
235 :rev => r1 | |
236 assert_response :success | |
237 assert_template 'entry' | |
238 assert_tag :tag => 'th', | |
239 :content => '1', | |
240 :attributes => { :class => 'line-num' }, | |
241 :sibling => { :tag => 'td', | |
242 :content => /test-#{@char_1}.txt/ } | |
243 end | |
244 end | |
245 end | |
246 end | |
247 | |
248 def test_entry_download | |
249 get :entry, :id => PRJ_ID, | |
250 :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param], | |
251 :format => 'raw' | |
252 assert_response :success | |
253 # File content | |
254 assert @response.body.include?('WITHOUT ANY WARRANTY') | |
255 end | |
256 | |
257 def test_directory_entry | |
258 get :entry, :id => PRJ_ID, | |
259 :path => repository_path_hash(['sources'])[:param] | |
260 assert_response :success | |
261 assert_template 'show' | |
262 assert_not_nil assigns(:entry) | |
263 assert_equal 'sources', assigns(:entry).name | |
264 end | |
265 | |
266 def test_diff | |
267 assert_equal true, @repository.is_default | |
268 assert_nil @repository.identifier | |
269 assert_equal 0, @repository.changesets.count | |
270 @repository.fetch_changesets | |
271 @project.reload | |
272 assert_equal NUM_REV, @repository.changesets.count | |
273 # Full diff of changeset 2f9c0091 | |
274 ['inline', 'sbs'].each do |dt| | |
275 get :diff, | |
276 :id => PRJ_ID, | |
277 :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7', | |
278 :type => dt | |
279 assert_response :success | |
280 assert_template 'diff' | |
281 # Line 22 removed | |
282 assert_tag :tag => 'th', | |
283 :content => /22/, | |
284 :sibling => { :tag => 'td', | |
285 :attributes => { :class => /diff_out/ }, | |
286 :content => /def remove/ } | |
287 assert_tag :tag => 'h2', :content => /2f9c0091/ | |
288 end | |
289 end | |
290 | |
291 def test_diff_with_rev_and_path | |
292 assert_equal 0, @repository.changesets.count | |
293 @repository.fetch_changesets | |
294 @project.reload | |
295 assert_equal NUM_REV, @repository.changesets.count | |
296 with_settings :diff_max_lines_displayed => 1000 do | |
297 # Full diff of changeset 2f9c0091 | |
298 ['inline', 'sbs'].each do |dt| | |
299 get :diff, | |
300 :id => PRJ_ID, | |
301 :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7', | |
302 :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param], | |
303 :type => dt | |
304 assert_response :success | |
305 assert_template 'diff' | |
306 # Line 22 removed | |
307 assert_tag :tag => 'th', | |
308 :content => '22', | |
309 :sibling => { :tag => 'td', | |
310 :attributes => { :class => /diff_out/ }, | |
311 :content => /def remove/ } | |
312 assert_tag :tag => 'h2', :content => /2f9c0091/ | |
313 end | |
314 end | |
315 end | |
316 | |
317 def test_diff_truncated | |
318 assert_equal 0, @repository.changesets.count | |
319 @repository.fetch_changesets | |
320 @project.reload | |
321 assert_equal NUM_REV, @repository.changesets.count | |
322 | |
323 with_settings :diff_max_lines_displayed => 5 do | |
324 # Truncated diff of changeset 2f9c0091 | |
325 with_cache do | |
326 with_settings :default_language => 'en' do | |
327 get :diff, :id => PRJ_ID, :type => 'inline', | |
328 :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' | |
329 assert_response :success | |
330 assert @response.body.include?("... This diff was truncated") | |
331 end | |
332 with_settings :default_language => 'fr' do | |
333 get :diff, :id => PRJ_ID, :type => 'inline', | |
334 :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' | |
335 assert_response :success | |
336 assert ! @response.body.include?("... This diff was truncated") | |
337 assert @response.body.include?("... Ce diff") | |
338 end | |
339 end | |
340 end | |
341 end | |
342 | |
343 def test_diff_two_revs | |
344 assert_equal 0, @repository.changesets.count | |
345 @repository.fetch_changesets | |
346 @project.reload | |
347 assert_equal NUM_REV, @repository.changesets.count | |
348 ['inline', 'sbs'].each do |dt| | |
349 get :diff, | |
350 :id => PRJ_ID, | |
351 :rev => '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', | |
352 :rev_to => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7', | |
353 :type => dt | |
354 assert_response :success | |
355 assert_template 'diff' | |
356 diff = assigns(:diff) | |
357 assert_not_nil diff | |
358 assert_tag :tag => 'h2', :content => /2f9c0091:61b685fb/ | |
359 assert_tag :tag => "form", | |
360 :attributes => { | |
361 :action => "/projects/subproject1/repository/revisions/" + | |
362 "61b685fbe55ab05b5ac68402d5720c1a6ac973d1/diff" | |
363 } | |
364 assert_tag :tag => 'input', | |
365 :attributes => { | |
366 :id => "rev_to", | |
367 :name => "rev_to", | |
368 :type => "hidden", | |
369 :value => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' | |
370 } | |
371 end | |
372 end | |
373 | |
374 def test_diff_path_in_subrepo | |
375 repo = Repository::Git.create( | |
376 :project => @project, | |
377 :url => REPOSITORY_PATH, | |
378 :identifier => 'test-diff-path', | |
379 :path_encoding => 'ISO-8859-1' | |
380 ); | |
381 assert repo | |
382 assert_equal false, repo.is_default | |
383 assert_equal 'test-diff-path', repo.identifier | |
384 get :diff, | |
385 :id => PRJ_ID, | |
386 :repository_id => 'test-diff-path', | |
387 :rev => '61b685fbe55ab05b', | |
388 :rev_to => '2f9c0091c754a91a', | |
389 :type => 'inline' | |
390 assert_response :success | |
391 assert_template 'diff' | |
392 diff = assigns(:diff) | |
393 assert_not_nil diff | |
394 assert_tag :tag => "form", | |
395 :attributes => { | |
396 :action => "/projects/subproject1/repository/test-diff-path/" + | |
397 "revisions/61b685fbe55ab05b/diff" | |
398 } | |
399 assert_tag :tag => 'input', | |
400 :attributes => { | |
401 :id => "rev_to", | |
402 :name => "rev_to", | |
403 :type => "hidden", | |
404 :value => '2f9c0091c754a91a' | |
405 } | |
406 end | |
407 | |
408 def test_diff_latin_1 | |
409 if @ruby19_non_utf8_pass | |
410 puts_ruby19_non_utf8_pass() | |
411 else | |
412 with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do | |
413 ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1| | |
414 ['inline', 'sbs'].each do |dt| | |
415 get :diff, :id => PRJ_ID, :rev => r1, :type => dt | |
416 assert_response :success | |
417 assert_template 'diff' | |
418 assert_tag :tag => 'thead', | |
419 :descendant => { | |
420 :tag => 'th', | |
421 :attributes => { :class => 'filename' } , | |
422 :content => /latin-1-dir\/test-#{@char_1}.txt/ , | |
423 }, | |
424 :sibling => { | |
425 :tag => 'tbody', | |
426 :descendant => { | |
427 :tag => 'td', | |
428 :attributes => { :class => /diff_in/ }, | |
429 :content => /test-#{@char_1}.txt/ | |
430 } | |
431 } | |
432 end | |
433 end | |
434 end | |
435 end | |
436 end | |
437 | |
438 def test_diff_should_show_filenames | |
439 get :diff, :id => PRJ_ID, :rev => 'deff712f05a90d96edbd70facc47d944be5897e3', :type => 'inline' | |
440 assert_response :success | |
441 assert_template 'diff' | |
442 # modified file | |
443 assert_select 'th.filename', :text => 'sources/watchers_controller.rb' | |
444 # deleted file | |
445 assert_select 'th.filename', :text => 'test.txt' | |
446 end | |
447 | |
448 def test_save_diff_type | |
449 user1 = User.find(1) | |
450 user1.pref[:diff_type] = nil | |
451 user1.preference.save | |
452 user = User.find(1) | |
453 assert_nil user.pref[:diff_type] | |
454 | |
455 @request.session[:user_id] = 1 # admin | |
456 get :diff, | |
457 :id => PRJ_ID, | |
458 :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' | |
459 assert_response :success | |
460 assert_template 'diff' | |
461 user.reload | |
462 assert_equal "inline", user.pref[:diff_type] | |
463 get :diff, | |
464 :id => PRJ_ID, | |
465 :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7', | |
466 :type => 'sbs' | |
467 assert_response :success | |
468 assert_template 'diff' | |
469 user.reload | |
470 assert_equal "sbs", user.pref[:diff_type] | |
471 end | |
472 | |
473 def test_annotate | |
474 get :annotate, :id => PRJ_ID, | |
475 :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param] | |
476 assert_response :success | |
477 assert_template 'annotate' | |
478 | |
479 # Line 23, changeset 2f9c0091 | |
480 assert_select 'tr' do | |
481 assert_select 'th.line-num', :text => '23' | |
482 assert_select 'td.revision', :text => /2f9c0091/ | |
483 assert_select 'td.author', :text => 'jsmith' | |
484 assert_select 'td', :text => /remove_watcher/ | |
485 end | |
486 end | |
487 | |
488 def test_annotate_at_given_revision | |
489 assert_equal 0, @repository.changesets.count | |
490 @repository.fetch_changesets | |
491 @project.reload | |
492 assert_equal NUM_REV, @repository.changesets.count | |
493 get :annotate, :id => PRJ_ID, :rev => 'deff7', | |
494 :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param] | |
495 assert_response :success | |
496 assert_template 'annotate' | |
497 assert_tag :tag => 'h2', :content => /@ deff712f/ | |
498 end | |
499 | |
500 def test_annotate_binary_file | |
501 get :annotate, :id => PRJ_ID, | |
502 :path => repository_path_hash(['images', 'edit.png'])[:param] | |
503 assert_response 500 | |
504 assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, | |
505 :content => /cannot be annotated/ | |
506 end | |
507 | |
508 def test_annotate_error_when_too_big | |
509 with_settings :file_max_size_displayed => 1 do | |
510 get :annotate, :id => PRJ_ID, | |
511 :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param], | |
512 :rev => 'deff712f' | |
513 assert_response 500 | |
514 assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, | |
515 :content => /exceeds the maximum text file size/ | |
516 | |
517 get :annotate, :id => PRJ_ID, | |
518 :path => repository_path_hash(['README'])[:param], | |
519 :rev => '7234cb2' | |
520 assert_response :success | |
521 assert_template 'annotate' | |
522 end | |
523 end | |
524 | |
525 def test_annotate_latin_1 | |
526 if @ruby19_non_utf8_pass | |
527 puts_ruby19_non_utf8_pass() | |
528 elsif WINDOWS_PASS | |
529 puts WINDOWS_SKIP_STR | |
530 elsif JRUBY_SKIP | |
531 puts JRUBY_SKIP_STR | |
532 else | |
533 with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do | |
534 ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1| | |
535 get :annotate, :id => PRJ_ID, | |
536 :path => repository_path_hash(['latin-1-dir', "test-#{@char_1}.txt"])[:param], | |
537 :rev => r1 | |
538 assert_select "th.line-num", :text => '1' do | |
539 assert_select "+ td.revision" do | |
540 assert_select "a", :text => '57ca437c' | |
541 assert_select "+ td.author", :text => "jsmith" do | |
542 assert_select "+ td", | |
543 :text => "test-#{@char_1}.txt" | |
544 end | |
545 end | |
546 end | |
547 end | |
548 end | |
549 end | |
550 end | |
551 | |
552 def test_annotate_latin_1_author | |
553 ['83ca5fd546063a3c7dc2e568ba3355661a9e2b2c', '83ca5fd546063a'].each do |r1| | |
554 get :annotate, :id => PRJ_ID, | |
555 :path => repository_path_hash([" filename with a leading space.txt "])[:param], | |
556 :rev => r1 | |
557 assert_select "th.line-num", :text => '1' do | |
558 assert_select "+ td.revision" do | |
559 assert_select "a", :text => '83ca5fd5' | |
560 assert_select "+ td.author", :text => @felix_utf8 do | |
561 assert_select "+ td", | |
562 :text => "And this is a file with a leading and trailing space..." | |
563 end | |
564 end | |
565 end | |
566 end | |
567 end | |
568 | |
569 def test_revisions | |
570 assert_equal 0, @repository.changesets.count | |
571 @repository.fetch_changesets | |
572 @project.reload | |
573 assert_equal NUM_REV, @repository.changesets.count | |
574 get :revisions, :id => PRJ_ID | |
575 assert_response :success | |
576 assert_template 'revisions' | |
577 assert_tag :tag => 'form', | |
578 :attributes => { | |
579 :method => 'get', | |
580 :action => '/projects/subproject1/repository/revision' | |
581 } | |
582 end | |
583 | |
584 def test_revision | |
585 assert_equal 0, @repository.changesets.count | |
586 @repository.fetch_changesets | |
587 @project.reload | |
588 assert_equal NUM_REV, @repository.changesets.count | |
589 ['61b685fbe55ab05b5ac68402d5720c1a6ac973d1', '61b685f'].each do |r| | |
590 get :revision, :id => PRJ_ID, :rev => r | |
591 assert_response :success | |
592 assert_template 'revision' | |
593 end | |
594 end | |
595 | |
596 def test_empty_revision | |
597 assert_equal 0, @repository.changesets.count | |
598 @repository.fetch_changesets | |
599 @project.reload | |
600 assert_equal NUM_REV, @repository.changesets.count | |
601 ['', ' ', nil].each do |r| | |
602 get :revision, :id => PRJ_ID, :rev => r | |
603 assert_response 404 | |
604 assert_error_tag :content => /was not found/ | |
605 end | |
606 end | |
607 | |
608 def test_destroy_valid_repository | |
609 @request.session[:user_id] = 1 # admin | |
610 assert_equal 0, @repository.changesets.count | |
611 @repository.fetch_changesets | |
612 @project.reload | |
613 assert_equal NUM_REV, @repository.changesets.count | |
614 | |
615 assert_difference 'Repository.count', -1 do | |
616 delete :destroy, :id => @repository.id | |
617 end | |
618 assert_response 302 | |
619 @project.reload | |
620 assert_nil @project.repository | |
621 end | |
622 | |
623 def test_destroy_invalid_repository | |
624 @request.session[:user_id] = 1 # admin | |
625 @project.repository.destroy | |
626 @repository = Repository::Git.create!( | |
627 :project => @project, | |
628 :url => "/invalid", | |
629 :path_encoding => 'ISO-8859-1' | |
630 ) | |
631 @repository.fetch_changesets | |
632 @repository.reload | |
633 assert_equal 0, @repository.changesets.count | |
634 | |
635 assert_difference 'Repository.count', -1 do | |
636 delete :destroy, :id => @repository.id | |
637 end | |
638 assert_response 302 | |
639 @project.reload | |
640 assert_nil @project.repository | |
641 end | |
642 | |
643 private | |
644 | |
645 def puts_ruby19_non_utf8_pass | |
646 puts "TODO: This test fails in Ruby 1.9 " + | |
647 "and Encoding.default_external is not UTF-8. " + | |
648 "Current value is '#{Encoding.default_external.to_s}'" | |
649 end | |
650 else | |
651 puts "Git test repository NOT FOUND. Skipping functional tests !!!" | |
652 def test_fake; assert true end | |
653 end | |
654 | |
655 private | |
656 def with_cache(&block) | |
657 before = ActionController::Base.perform_caching | |
658 ActionController::Base.perform_caching = true | |
659 block.call | |
660 ActionController::Base.perform_caching = before | |
661 end | |
662 end |