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