@@ -1,484 +1,486 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2011 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 | require 'repositories_controller' |
|
20 | 20 | |
|
21 | 21 | # Re-raise errors caught by the controller. |
|
22 | 22 | class RepositoriesController; def rescue_action(e) raise e end; end |
|
23 | 23 | |
|
24 | 24 | class RepositoriesMercurialControllerTest < ActionController::TestCase |
|
25 | 25 | fixtures :projects, :users, :roles, :members, :member_roles, |
|
26 | 26 | :repositories, :enabled_modules |
|
27 | 27 | |
|
28 | 28 | REPOSITORY_PATH = Rails.root.join('tmp/test/mercurial_repository').to_s |
|
29 | 29 | CHAR_1_HEX = "\xc3\x9c" |
|
30 | 30 | PRJ_ID = 3 |
|
31 | 31 | NUM_REV = 29 |
|
32 | 32 | |
|
33 | 33 | ruby19_non_utf8_pass = |
|
34 | 34 | (RUBY_VERSION >= '1.9' && Encoding.default_external.to_s != 'UTF-8') |
|
35 | 35 | |
|
36 | 36 | def setup |
|
37 | 37 | @controller = RepositoriesController.new |
|
38 | 38 | @request = ActionController::TestRequest.new |
|
39 | 39 | @response = ActionController::TestResponse.new |
|
40 | 40 | User.current = nil |
|
41 | 41 | @project = Project.find(PRJ_ID) |
|
42 | 42 | @repository = Repository::Mercurial.create( |
|
43 | 43 | :project => @project, |
|
44 | 44 | :url => REPOSITORY_PATH, |
|
45 | 45 | :path_encoding => 'ISO-8859-1' |
|
46 | 46 | ) |
|
47 | 47 | assert @repository |
|
48 | 48 | @diff_c_support = true |
|
49 | 49 | @char_1 = CHAR_1_HEX.dup |
|
50 | 50 | @tag_char_1 = "tag-#{CHAR_1_HEX}-00" |
|
51 | 51 | @branch_char_0 = "branch-#{CHAR_1_HEX}-00" |
|
52 | 52 | @branch_char_1 = "branch-#{CHAR_1_HEX}-01" |
|
53 | 53 | if @char_1.respond_to?(:force_encoding) |
|
54 | 54 | @char_1.force_encoding('UTF-8') |
|
55 | 55 | @tag_char_1.force_encoding('UTF-8') |
|
56 | 56 | @branch_char_0.force_encoding('UTF-8') |
|
57 | 57 | @branch_char_1.force_encoding('UTF-8') |
|
58 | 58 | end |
|
59 | 59 | end |
|
60 | 60 | |
|
61 | 61 | if ruby19_non_utf8_pass |
|
62 | 62 | puts "TODO: Mercurial functional test fails in Ruby 1.9 " + |
|
63 | 63 | "and Encoding.default_external is not UTF-8. " + |
|
64 | 64 | "Current value is '#{Encoding.default_external.to_s}'" |
|
65 | 65 | def test_fake; assert true end |
|
66 | 66 | elsif File.directory?(REPOSITORY_PATH) |
|
67 | 67 | def test_show_root |
|
68 | 68 | assert_equal 0, @repository.changesets.count |
|
69 | 69 | @repository.fetch_changesets |
|
70 | 70 | @project.reload |
|
71 | 71 | assert_equal NUM_REV, @repository.changesets.count |
|
72 | 72 | get :show, :id => PRJ_ID |
|
73 | 73 | assert_response :success |
|
74 | 74 | assert_template 'show' |
|
75 | 75 | assert_not_nil assigns(:entries) |
|
76 | 76 | assert_equal 4, assigns(:entries).size |
|
77 | 77 | assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'} |
|
78 | 78 | assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'} |
|
79 | 79 | assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'} |
|
80 | 80 | assert_not_nil assigns(:changesets) |
|
81 | 81 | assert assigns(:changesets).size > 0 |
|
82 | 82 | end |
|
83 | 83 | |
|
84 | 84 | def test_show_directory |
|
85 | 85 | assert_equal 0, @repository.changesets.count |
|
86 | 86 | @repository.fetch_changesets |
|
87 | 87 | @project.reload |
|
88 | 88 | assert_equal NUM_REV, @repository.changesets.count |
|
89 | 89 | get :show, :id => PRJ_ID, :path => ['images'] |
|
90 | 90 | assert_response :success |
|
91 | 91 | assert_template 'show' |
|
92 | 92 | assert_not_nil assigns(:entries) |
|
93 | 93 | assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name) |
|
94 | 94 | entry = assigns(:entries).detect {|e| e.name == 'edit.png'} |
|
95 | 95 | assert_not_nil entry |
|
96 | 96 | assert_equal 'file', entry.kind |
|
97 | 97 | assert_equal 'images/edit.png', entry.path |
|
98 | 98 | assert_not_nil assigns(:changesets) |
|
99 | 99 | assert assigns(:changesets).size > 0 |
|
100 | 100 | end |
|
101 | 101 | |
|
102 | 102 | def test_show_at_given_revision |
|
103 | assert_equal 0, @repository.changesets.count | |
|
103 | 104 | @repository.fetch_changesets |
|
104 |
@ |
|
|
105 | @project.reload | |
|
106 | assert_equal NUM_REV, @repository.changesets.count | |
|
105 | 107 | [0, '0', '0885933ad4f6'].each do |r1| |
|
106 | 108 | get :show, :id => PRJ_ID, :path => ['images'], :rev => r1 |
|
107 | 109 | assert_response :success |
|
108 | 110 | assert_template 'show' |
|
109 | 111 | assert_not_nil assigns(:entries) |
|
110 | 112 | assert_equal ['delete.png'], assigns(:entries).collect(&:name) |
|
111 | 113 | assert_not_nil assigns(:changesets) |
|
112 | 114 | assert assigns(:changesets).size > 0 |
|
113 | 115 | end |
|
114 | 116 | end |
|
115 | 117 | |
|
116 | 118 | def test_show_directory_sql_escape_percent |
|
117 | 119 | @repository.fetch_changesets |
|
118 | 120 | @repository.reload |
|
119 | 121 | [13, '13', '3a330eb32958'].each do |r1| |
|
120 | 122 | get :show, :id => PRJ_ID, :path => ['sql_escape', 'percent%dir'], |
|
121 | 123 | :rev => r1 |
|
122 | 124 | assert_response :success |
|
123 | 125 | assert_template 'show' |
|
124 | 126 | |
|
125 | 127 | assert_not_nil assigns(:entries) |
|
126 | 128 | assert_equal ['percent%file1.txt', 'percentfile1.txt'], |
|
127 | 129 | assigns(:entries).collect(&:name) |
|
128 | 130 | changesets = assigns(:changesets) |
|
129 | 131 | assert_not_nil changesets |
|
130 | 132 | assert assigns(:changesets).size > 0 |
|
131 | 133 | assert_equal %w(13 11 10 9), changesets.collect(&:revision) |
|
132 | 134 | end |
|
133 | 135 | end |
|
134 | 136 | |
|
135 | 137 | def test_show_directory_latin_1_path |
|
136 | 138 | @repository.fetch_changesets |
|
137 | 139 | @repository.reload |
|
138 | 140 | [21, '21', 'adf805632193'].each do |r1| |
|
139 | 141 | get :show, :id => PRJ_ID, :path => ['latin-1-dir'], :rev => r1 |
|
140 | 142 | assert_response :success |
|
141 | 143 | assert_template 'show' |
|
142 | 144 | |
|
143 | 145 | assert_not_nil assigns(:entries) |
|
144 | 146 | assert_equal ["make-latin-1-file.rb", |
|
145 | 147 | "test-#{@char_1}-1.txt", |
|
146 | 148 | "test-#{@char_1}-2.txt", |
|
147 | 149 | "test-#{@char_1}.txt"], assigns(:entries).collect(&:name) |
|
148 | 150 | changesets = assigns(:changesets) |
|
149 | 151 | assert_not_nil changesets |
|
150 | 152 | assert_equal %w(21 20 19 18 17), changesets.collect(&:revision) |
|
151 | 153 | end |
|
152 | 154 | end |
|
153 | 155 | |
|
154 | 156 | def test_show_branch |
|
155 | 157 | @repository.fetch_changesets |
|
156 | 158 | @repository.reload |
|
157 | 159 | [ |
|
158 | 160 | 'default', |
|
159 | 161 | @branch_char_1, |
|
160 | 162 | 'branch (1)[2]&,%.-3_4', |
|
161 | 163 | @branch_char_0, |
|
162 | 164 | 'test_branch.latin-1', |
|
163 | 165 | 'test-branch-00', |
|
164 | 166 | ].each do |bra| |
|
165 | 167 | get :show, :id => PRJ_ID, :rev => bra |
|
166 | 168 | assert_response :success |
|
167 | 169 | assert_template 'show' |
|
168 | 170 | assert_not_nil assigns(:entries) |
|
169 | 171 | assert assigns(:entries).size > 0 |
|
170 | 172 | assert_not_nil assigns(:changesets) |
|
171 | 173 | assert assigns(:changesets).size > 0 |
|
172 | 174 | end |
|
173 | 175 | end |
|
174 | 176 | |
|
175 | 177 | def test_show_tag |
|
176 | 178 | @repository.fetch_changesets |
|
177 | 179 | @repository.reload |
|
178 | 180 | [ |
|
179 | 181 | @tag_char_1, |
|
180 | 182 | 'tag_test.00', |
|
181 | 183 | 'tag-init-revision' |
|
182 | 184 | ].each do |tag| |
|
183 | 185 | get :show, :id => PRJ_ID, :rev => tag |
|
184 | 186 | assert_response :success |
|
185 | 187 | assert_template 'show' |
|
186 | 188 | assert_not_nil assigns(:entries) |
|
187 | 189 | assert assigns(:entries).size > 0 |
|
188 | 190 | assert_not_nil assigns(:changesets) |
|
189 | 191 | assert assigns(:changesets).size > 0 |
|
190 | 192 | end |
|
191 | 193 | end |
|
192 | 194 | |
|
193 | 195 | def test_changes |
|
194 | 196 | get :changes, :id => PRJ_ID, :path => ['images', 'edit.png'] |
|
195 | 197 | assert_response :success |
|
196 | 198 | assert_template 'changes' |
|
197 | 199 | assert_tag :tag => 'h2', :content => 'edit.png' |
|
198 | 200 | end |
|
199 | 201 | |
|
200 | 202 | def test_entry_show |
|
201 | 203 | get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'] |
|
202 | 204 | assert_response :success |
|
203 | 205 | assert_template 'entry' |
|
204 | 206 | # Line 10 |
|
205 | 207 | assert_tag :tag => 'th', |
|
206 | 208 | :content => '10', |
|
207 | 209 | :attributes => { :class => 'line-num' }, |
|
208 | 210 | :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ } |
|
209 | 211 | end |
|
210 | 212 | |
|
211 | 213 | def test_entry_show_latin_1_path |
|
212 | 214 | [21, '21', 'adf805632193'].each do |r1| |
|
213 | 215 | get :entry, :id => PRJ_ID, |
|
214 | 216 | :path => ['latin-1-dir', "test-#{@char_1}-2.txt"], :rev => r1 |
|
215 | 217 | assert_response :success |
|
216 | 218 | assert_template 'entry' |
|
217 | 219 | assert_tag :tag => 'th', |
|
218 | 220 | :content => '1', |
|
219 | 221 | :attributes => { :class => 'line-num' }, |
|
220 | 222 | :sibling => { :tag => 'td', |
|
221 | 223 | :content => /Mercurial is a distributed version control system/ } |
|
222 | 224 | end |
|
223 | 225 | end |
|
224 | 226 | |
|
225 | 227 | def test_entry_show_latin_1_contents |
|
226 | 228 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do |
|
227 | 229 | [27, '27', '7bbf4c738e71'].each do |r1| |
|
228 | 230 | get :entry, :id => PRJ_ID, |
|
229 | 231 | :path => ['latin-1-dir', "test-#{@char_1}.txt"], :rev => r1 |
|
230 | 232 | assert_response :success |
|
231 | 233 | assert_template 'entry' |
|
232 | 234 | assert_tag :tag => 'th', |
|
233 | 235 | :content => '1', |
|
234 | 236 | :attributes => { :class => 'line-num' }, |
|
235 | 237 | :sibling => { :tag => 'td', |
|
236 | 238 | :content => /test-#{@char_1}.txt/ } |
|
237 | 239 | end |
|
238 | 240 | end |
|
239 | 241 | end |
|
240 | 242 | |
|
241 | 243 | def test_entry_download |
|
242 | 244 | get :entry, :id => PRJ_ID, |
|
243 | 245 | :path => ['sources', 'watchers_controller.rb'], :format => 'raw' |
|
244 | 246 | assert_response :success |
|
245 | 247 | # File content |
|
246 | 248 | assert @response.body.include?('WITHOUT ANY WARRANTY') |
|
247 | 249 | end |
|
248 | 250 | |
|
249 | 251 | def test_entry_binary_force_download |
|
250 | 252 | get :entry, :id => PRJ_ID, :rev => 1, :path => ['images', 'edit.png'] |
|
251 | 253 | assert_response :success |
|
252 | 254 | assert_equal 'image/png', @response.content_type |
|
253 | 255 | end |
|
254 | 256 | |
|
255 | 257 | def test_directory_entry |
|
256 | 258 | get :entry, :id => PRJ_ID, :path => ['sources'] |
|
257 | 259 | assert_response :success |
|
258 | 260 | assert_template 'show' |
|
259 | 261 | assert_not_nil assigns(:entry) |
|
260 | 262 | assert_equal 'sources', assigns(:entry).name |
|
261 | 263 | end |
|
262 | 264 | |
|
263 | 265 | def test_diff |
|
264 | 266 | @repository.fetch_changesets |
|
265 | 267 | @repository.reload |
|
266 | 268 | [4, '4', 'def6d2f1254a'].each do |r1| |
|
267 | 269 | # Full diff of changeset 4 |
|
268 | 270 | ['inline', 'sbs'].each do |dt| |
|
269 | 271 | get :diff, :id => PRJ_ID, :rev => r1, :type => dt |
|
270 | 272 | assert_response :success |
|
271 | 273 | assert_template 'diff' |
|
272 | 274 | if @diff_c_support |
|
273 | 275 | # Line 22 removed |
|
274 | 276 | assert_tag :tag => 'th', |
|
275 | 277 | :content => '22', |
|
276 | 278 | :sibling => { :tag => 'td', |
|
277 | 279 | :attributes => { :class => /diff_out/ }, |
|
278 | 280 | :content => /def remove/ } |
|
279 | 281 | assert_tag :tag => 'h2', :content => /4:def6d2f1254a/ |
|
280 | 282 | end |
|
281 | 283 | end |
|
282 | 284 | end |
|
283 | 285 | end |
|
284 | 286 | |
|
285 | 287 | def test_diff_two_revs |
|
286 | 288 | @repository.fetch_changesets |
|
287 | 289 | @repository.reload |
|
288 | 290 | [2, '400bb8672109', '400', 400].each do |r1| |
|
289 | 291 | [4, 'def6d2f1254a'].each do |r2| |
|
290 | 292 | ['inline', 'sbs'].each do |dt| |
|
291 | 293 | get :diff, |
|
292 | 294 | :id => PRJ_ID, |
|
293 | 295 | :rev => r1, |
|
294 | 296 | :rev_to => r2, |
|
295 | 297 | :type => dt |
|
296 | 298 | assert_response :success |
|
297 | 299 | assert_template 'diff' |
|
298 | 300 | diff = assigns(:diff) |
|
299 | 301 | assert_not_nil diff |
|
300 | 302 | assert_tag :tag => 'h2', |
|
301 | 303 | :content => /4:def6d2f1254a 2:400bb8672109/ |
|
302 | 304 | end |
|
303 | 305 | end |
|
304 | 306 | end |
|
305 | 307 | end |
|
306 | 308 | |
|
307 | 309 | def test_diff_latin_1_path |
|
308 | 310 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do |
|
309 | 311 | [21, 'adf805632193'].each do |r1| |
|
310 | 312 | ['inline', 'sbs'].each do |dt| |
|
311 | 313 | get :diff, :id => PRJ_ID, :rev => r1, :type => dt |
|
312 | 314 | assert_response :success |
|
313 | 315 | assert_template 'diff' |
|
314 | 316 | assert_tag :tag => 'thead', |
|
315 | 317 | :descendant => { |
|
316 | 318 | :tag => 'th', |
|
317 | 319 | :attributes => { :class => 'filename' } , |
|
318 | 320 | :content => /latin-1-dir\/test-#{@char_1}-2.txt/ , |
|
319 | 321 | }, |
|
320 | 322 | :sibling => { |
|
321 | 323 | :tag => 'tbody', |
|
322 | 324 | :descendant => { |
|
323 | 325 | :tag => 'td', |
|
324 | 326 | :attributes => { :class => /diff_in/ }, |
|
325 | 327 | :content => /It is written in Python/ |
|
326 | 328 | } |
|
327 | 329 | } |
|
328 | 330 | end |
|
329 | 331 | end |
|
330 | 332 | end |
|
331 | 333 | end |
|
332 | 334 | |
|
333 | 335 | def test_annotate |
|
334 | 336 | get :annotate, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'] |
|
335 | 337 | assert_response :success |
|
336 | 338 | assert_template 'annotate' |
|
337 | 339 | # Line 23, revision 4:def6d2f1254a |
|
338 | 340 | assert_tag :tag => 'th', |
|
339 | 341 | :content => '23', |
|
340 | 342 | :attributes => { :class => 'line-num' }, |
|
341 | 343 | :sibling => |
|
342 | 344 | { |
|
343 | 345 | :tag => 'td', |
|
344 | 346 | :attributes => { :class => 'revision' }, |
|
345 | 347 | :child => { :tag => 'a', :content => '4:def6d2f1254a' } |
|
346 | 348 | } |
|
347 | 349 | assert_tag :tag => 'th', |
|
348 | 350 | :content => '23', |
|
349 | 351 | :attributes => { :class => 'line-num' }, |
|
350 | 352 | :sibling => |
|
351 | 353 | { |
|
352 | 354 | :tag => 'td' , |
|
353 | 355 | :content => 'jsmith' , |
|
354 | 356 | :attributes => { :class => 'author' }, |
|
355 | 357 | } |
|
356 | 358 | assert_tag :tag => 'th', |
|
357 | 359 | :content => '23', |
|
358 | 360 | :attributes => { :class => 'line-num' }, |
|
359 | 361 | :sibling => { :tag => 'td', :content => /watcher =/ } |
|
360 | 362 | end |
|
361 | 363 | |
|
362 | 364 | def test_annotate_not_in_tip |
|
363 | 365 | @repository.fetch_changesets |
|
364 | 366 | @repository.reload |
|
365 | 367 | assert @repository.changesets.size > 0 |
|
366 | 368 | |
|
367 | 369 | get :annotate, :id => PRJ_ID, |
|
368 | 370 | :path => ['sources', 'welcome_controller.rb'] |
|
369 | 371 | assert_response 404 |
|
370 | 372 | assert_error_tag :content => /was not found/ |
|
371 | 373 | end |
|
372 | 374 | |
|
373 | 375 | def test_annotate_at_given_revision |
|
374 | 376 | @repository.fetch_changesets |
|
375 | 377 | @repository.reload |
|
376 | 378 | [2, '400bb8672109', '400', 400].each do |r1| |
|
377 | 379 | get :annotate, :id => PRJ_ID, :rev => r1, |
|
378 | 380 | :path => ['sources', 'watchers_controller.rb'] |
|
379 | 381 | assert_response :success |
|
380 | 382 | assert_template 'annotate' |
|
381 | 383 | assert_tag :tag => 'h2', :content => /@ 2:400bb8672109/ |
|
382 | 384 | end |
|
383 | 385 | end |
|
384 | 386 | |
|
385 | 387 | def test_annotate_latin_1_path |
|
386 | 388 | [21, '21', 'adf805632193'].each do |r1| |
|
387 | 389 | get :annotate, :id => PRJ_ID, |
|
388 | 390 | :path => ['latin-1-dir', "test-#{@char_1}-2.txt"], :rev => r1 |
|
389 | 391 | assert_response :success |
|
390 | 392 | assert_template 'annotate' |
|
391 | 393 | assert_tag :tag => 'th', |
|
392 | 394 | :content => '1', |
|
393 | 395 | :attributes => { :class => 'line-num' }, |
|
394 | 396 | :sibling => |
|
395 | 397 | { |
|
396 | 398 | :tag => 'td', |
|
397 | 399 | :attributes => { :class => 'revision' }, |
|
398 | 400 | :child => { :tag => 'a', :content => '20:709858aafd1b' } |
|
399 | 401 | } |
|
400 | 402 | assert_tag :tag => 'th', |
|
401 | 403 | :content => '1', |
|
402 | 404 | :attributes => { :class => 'line-num' }, |
|
403 | 405 | :sibling => |
|
404 | 406 | { |
|
405 | 407 | :tag => 'td' , |
|
406 | 408 | :content => 'jsmith' , |
|
407 | 409 | :attributes => { :class => 'author' }, |
|
408 | 410 | } |
|
409 | 411 | assert_tag :tag => 'th', |
|
410 | 412 | :content => '1', |
|
411 | 413 | :attributes => { :class => 'line-num' }, |
|
412 | 414 | :sibling => { :tag => 'td', |
|
413 | 415 | :content => /Mercurial is a distributed version control system/ } |
|
414 | 416 | |
|
415 | 417 | end |
|
416 | 418 | end |
|
417 | 419 | |
|
418 | 420 | def test_annotate_latin_1_contents |
|
419 | 421 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do |
|
420 | 422 | [27, '7bbf4c738e71'].each do |r1| |
|
421 | 423 | get :annotate, :id => PRJ_ID, |
|
422 | 424 | :path => ['latin-1-dir', "test-#{@char_1}.txt"], :rev => r1 |
|
423 | 425 | assert_tag :tag => 'th', |
|
424 | 426 | :content => '1', |
|
425 | 427 | :attributes => { :class => 'line-num' }, |
|
426 | 428 | :sibling => { :tag => 'td', |
|
427 | 429 | :content => /test-#{@char_1}.txt/ } |
|
428 | 430 | end |
|
429 | 431 | end |
|
430 | 432 | end |
|
431 | 433 | |
|
432 | 434 | def test_empty_revision |
|
433 | 435 | @repository.fetch_changesets |
|
434 | 436 | @repository.reload |
|
435 | 437 | ['', ' ', nil].each do |r| |
|
436 | 438 | get :revision, :id => PRJ_ID, :rev => r |
|
437 | 439 | assert_response 404 |
|
438 | 440 | assert_error_tag :content => /was not found/ |
|
439 | 441 | end |
|
440 | 442 | end |
|
441 | 443 | |
|
442 | 444 | def test_destroy_valid_repository |
|
443 | 445 | @request.session[:user_id] = 1 # admin |
|
444 | 446 | @repository.fetch_changesets |
|
445 | 447 | @repository.reload |
|
446 | 448 | assert @repository.changesets.count > 0 |
|
447 | 449 | |
|
448 | 450 | get :destroy, :id => PRJ_ID |
|
449 | 451 | assert_response 302 |
|
450 | 452 | @project.reload |
|
451 | 453 | assert_nil @project.repository |
|
452 | 454 | end |
|
453 | 455 | |
|
454 | 456 | def test_destroy_invalid_repository |
|
455 | 457 | @request.session[:user_id] = 1 # admin |
|
456 | 458 | @repository.fetch_changesets |
|
457 | 459 | @repository.reload |
|
458 | 460 | assert @repository.changesets.count > 0 |
|
459 | 461 | |
|
460 | 462 | get :destroy, :id => PRJ_ID |
|
461 | 463 | assert_response 302 |
|
462 | 464 | @project.reload |
|
463 | 465 | assert_nil @project.repository |
|
464 | 466 | |
|
465 | 467 | @repository = Repository::Mercurial.create( |
|
466 | 468 | :project => Project.find(PRJ_ID), |
|
467 | 469 | :url => "/invalid", |
|
468 | 470 | :path_encoding => 'ISO-8859-1' |
|
469 | 471 | ) |
|
470 | 472 | assert @repository |
|
471 | 473 | @repository.fetch_changesets |
|
472 | 474 | @repository.reload |
|
473 | 475 | assert_equal 0, @repository.changesets.count |
|
474 | 476 | |
|
475 | 477 | get :destroy, :id => PRJ_ID |
|
476 | 478 | assert_response 302 |
|
477 | 479 | @project.reload |
|
478 | 480 | assert_nil @project.repository |
|
479 | 481 | end |
|
480 | 482 | else |
|
481 | 483 | puts "Mercurial test repository NOT FOUND. Skipping functional tests !!!" |
|
482 | 484 | def test_fake; assert true end |
|
483 | 485 | end |
|
484 | 486 | end |
General Comments 0
You need to be logged in to leave comments.
Login now