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