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