##// END OF EJS Templates
Adds a test for #21100....
Jean-Philippe Lang -
r14473:9fc0d230c888
parent child
Show More
@@ -1,590 +1,608
1 1 # encoding: utf-8
2 2 #
3 3 # Redmine - project management software
4 4 # Copyright (C) 2006-2015 Jean-Philippe Lang
5 5 #
6 6 # This program is free software; you can redistribute it and/or
7 7 # modify it under the terms of the GNU General Public License
8 8 # as published by the Free Software Foundation; either version 2
9 9 # of the License, or (at your option) any later version.
10 10 #
11 11 # This program is distributed in the hope that it will be useful,
12 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 14 # GNU General Public License for more details.
15 15 #
16 16 # You should have received a copy of the GNU General Public License
17 17 # along with this program; if not, write to the Free Software
18 18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 19
20 20 require File.expand_path('../../test_helper', __FILE__)
21 21
22 22 class ChangesetTest < ActiveSupport::TestCase
23 23 fixtures :projects, :repositories,
24 24 :issues, :issue_statuses, :issue_categories,
25 25 :journals, :journal_details,
26 26 :workflows,
27 27 :changesets, :changes,
28 28 :enumerations,
29 29 :custom_fields, :custom_values,
30 30 :users, :members, :member_roles,
31 31 :email_addresses,
32 32 :trackers, :projects_trackers,
33 33 :enabled_modules, :roles
34 34
35 35 def test_ref_keywords_any
36 36 ActionMailer::Base.deliveries.clear
37 37 Setting.commit_ref_keywords = '*'
38 38 Setting.commit_update_keywords = [{'keywords' => 'fixes , closes', 'status_id' => '5', 'done_ratio' => '90'}]
39 39
40 40 c = Changeset.new(:repository => Project.find(1).repository,
41 41 :committed_on => Time.now,
42 42 :comments => 'New commit (#2). Fixes #1',
43 43 :revision => '12345')
44 44 assert c.save
45 45 assert_equal [1, 2], c.issue_ids.sort
46 46 fixed = Issue.find(1)
47 47 assert fixed.closed?
48 48 assert_equal 90, fixed.done_ratio
49 49 assert_equal 1, ActionMailer::Base.deliveries.size
50 50 end
51 51
52 52 def test_ref_keywords
53 53 Setting.commit_ref_keywords = 'refs'
54 54 Setting.commit_update_keywords = ''
55 55 c = Changeset.new(:repository => Project.find(1).repository,
56 56 :committed_on => Time.now,
57 57 :comments => 'Ignores #2. Refs #1',
58 58 :revision => '12345')
59 59 assert c.save
60 60 assert_equal [1], c.issue_ids.sort
61 61 end
62 62
63 63 def test_ref_keywords_any_only
64 64 Setting.commit_ref_keywords = '*'
65 65 Setting.commit_update_keywords = ''
66 66 c = Changeset.new(:repository => Project.find(1).repository,
67 67 :committed_on => Time.now,
68 68 :comments => 'Ignores #2. Refs #1',
69 69 :revision => '12345')
70 70 assert c.save
71 71 assert_equal [1, 2], c.issue_ids.sort
72 72 end
73 73
74 74 def test_ref_keywords_any_with_timelog
75 75 Setting.commit_ref_keywords = '*'
76 76 Setting.commit_logtime_enabled = '1'
77 77
78 78 {
79 79 '2' => 2.0,
80 80 '2h' => 2.0,
81 81 '2hours' => 2.0,
82 82 '15m' => 0.25,
83 83 '15min' => 0.25,
84 84 '3h15' => 3.25,
85 85 '3h15m' => 3.25,
86 86 '3h15min' => 3.25,
87 87 '3:15' => 3.25,
88 88 '3.25' => 3.25,
89 89 '3.25h' => 3.25,
90 90 '3,25' => 3.25,
91 91 '3,25h' => 3.25,
92 92 }.each do |syntax, expected_hours|
93 93 c = Changeset.new(:repository => Project.find(1).repository,
94 94 :committed_on => 24.hours.ago,
95 95 :comments => "Worked on this issue #1 @#{syntax}",
96 96 :revision => '520',
97 97 :user => User.find(2))
98 98 assert_difference 'TimeEntry.count' do
99 99 c.scan_comment_for_issue_ids
100 100 end
101 101 assert_equal [1], c.issue_ids.sort
102 102
103 103 time = TimeEntry.order('id desc').first
104 104 assert_equal 1, time.issue_id
105 105 assert_equal 1, time.project_id
106 106 assert_equal 2, time.user_id
107 107 assert_equal expected_hours, time.hours,
108 108 "@#{syntax} should be logged as #{expected_hours} hours but was #{time.hours}"
109 109 assert_equal Date.yesterday, time.spent_on
110 110 assert time.activity.is_default?
111 111 assert time.comments.include?('r520'),
112 112 "r520 was expected in time_entry comments: #{time.comments}"
113 113 end
114 114 end
115 115
116 116 def test_ref_keywords_closing_with_timelog
117 117 Setting.commit_ref_keywords = '*'
118 118 Setting.commit_update_keywords = [{'keywords' => 'fixes , closes',
119 119 'status_id' => IssueStatus.where(:is_closed => true).first.id.to_s}]
120 120 Setting.commit_logtime_enabled = '1'
121 121
122 122 c = Changeset.new(:repository => Project.find(1).repository,
123 123 :committed_on => Time.now,
124 124 :comments => 'This is a comment. Fixes #1 @4.5, #2 @1',
125 125 :user => User.find(2))
126 126 assert_difference 'TimeEntry.count', 2 do
127 127 c.scan_comment_for_issue_ids
128 128 end
129 129
130 130 assert_equal [1, 2], c.issue_ids.sort
131 131 assert Issue.find(1).closed?
132 132 assert Issue.find(2).closed?
133 133
134 134 times = TimeEntry.order('id desc').limit(2)
135 135 assert_equal [1, 2], times.collect(&:issue_id).sort
136 136 end
137 137
138 138 def test_ref_keywords_any_line_start
139 139 Setting.commit_ref_keywords = '*'
140 140 c = Changeset.new(:repository => Project.find(1).repository,
141 141 :committed_on => Time.now,
142 142 :comments => '#1 is the reason of this commit',
143 143 :revision => '12345')
144 144 assert c.save
145 145 assert_equal [1], c.issue_ids.sort
146 146 end
147 147
148 148 def test_ref_keywords_allow_brackets_around_a_issue_number
149 149 Setting.commit_ref_keywords = '*'
150 150 c = Changeset.new(:repository => Project.find(1).repository,
151 151 :committed_on => Time.now,
152 152 :comments => '[#1] Worked on this issue',
153 153 :revision => '12345')
154 154 assert c.save
155 155 assert_equal [1], c.issue_ids.sort
156 156 end
157 157
158 158 def test_ref_keywords_allow_brackets_around_multiple_issue_numbers
159 159 Setting.commit_ref_keywords = '*'
160 160 c = Changeset.new(:repository => Project.find(1).repository,
161 161 :committed_on => Time.now,
162 162 :comments => '[#1 #2, #3] Worked on these',
163 163 :revision => '12345')
164 164 assert c.save
165 165 assert_equal [1,2,3], c.issue_ids.sort
166 166 end
167 167
168 168 def test_ref_keywords_with_large_number_should_not_error
169 169 Setting.commit_ref_keywords = '*'
170 170 c = Changeset.new(:repository => Project.find(1).repository,
171 171 :committed_on => Time.now,
172 172 :comments => 'Out of range #2010021810000121',
173 173 :revision => '12345')
174 174 assert_nothing_raised do
175 175 assert c.save
176 176 end
177 177 assert_equal [], c.issue_ids.sort
178 178 end
179 179
180 180 def test_update_keywords_with_changes_should_create_journal
181 181 issue = Issue.generate!(:project_id => 1, :status_id => 1)
182 182
183 183 with_settings :commit_update_keywords => [{'keywords' => 'fixes', 'status_id' => '3'}] do
184 184 assert_difference 'Journal.count' do
185 185 c = Changeset.generate!(:repository => Project.find(1).repository,:comments => "Fixes ##{issue.id}")
186 186 assert_include c.id, issue.reload.changeset_ids
187 187 journal = Journal.order('id DESC').first
188 188 assert_equal 1, journal.details.count
189 189 end
190 190 end
191 191 end
192 192
193 193 def test_update_keywords_without_change_should_not_create_journal
194 194 issue = Issue.generate!(:project_id => 1, :status_id => 3)
195 195
196 196 with_settings :commit_update_keywords => [{'keywords' => 'fixes', 'status_id' => '3'}] do
197 197 assert_no_difference 'Journal.count' do
198 198 c = Changeset.generate!(:repository => Project.find(1).repository,:comments => "Fixes ##{issue.id}")
199 199 assert_include c.id, issue.reload.changeset_ids
200 200 end
201 201 end
202 202 end
203 203
204 204 def test_update_keywords_with_multiple_rules
205 205 with_settings :commit_update_keywords => [
206 206 {'keywords' => 'fixes, closes', 'status_id' => '5'},
207 207 {'keywords' => 'resolves', 'status_id' => '3'}
208 208 ] do
209 209
210 210 issue1 = Issue.generate!
211 211 issue2 = Issue.generate!
212 212 Changeset.generate!(:comments => "Closes ##{issue1.id}\nResolves ##{issue2.id}")
213 213 assert_equal 5, issue1.reload.status_id
214 214 assert_equal 3, issue2.reload.status_id
215 215 end
216 216 end
217 217
218 def test_update_keywords_with_multiple_rules_should_match_tracker
218 def test_update_keywords_with_multiple_rules_for_the_same_keyword_should_match_tracker
219 219 with_settings :commit_update_keywords => [
220 220 {'keywords' => 'fixes', 'status_id' => '5', 'if_tracker_id' => '2'},
221 221 {'keywords' => 'fixes', 'status_id' => '3', 'if_tracker_id' => ''}
222 222 ] do
223 223
224 224 issue1 = Issue.generate!(:tracker_id => 2)
225 225 issue2 = Issue.generate!
226 226 Changeset.generate!(:comments => "Fixes ##{issue1.id}, ##{issue2.id}")
227 227 assert_equal 5, issue1.reload.status_id
228 228 assert_equal 3, issue2.reload.status_id
229 229 end
230 230 end
231 231
232 def test_update_keywords_with_multiple_rules_for_the_same_tracker_should_match_keyword
233 with_settings :commit_update_keywords => [
234 {'keywords' => 'Fixes, Closes', 'status_id' => '5', 'done_ratio' => '100', 'if_tracker_id' => '2'},
235 {'keywords' => 'Testing', 'status_id' => '3', 'done_ratio' => '90', 'if_tracker_id' => '2'}
236 ] do
237
238 issue1 = Issue.generate!(:tracker_id => 2)
239 issue2 = Issue.generate!(:tracker_id => 2)
240 Changeset.generate!(:comments => "Testing ##{issue1.id}, Fixes ##{issue2.id}")
241 issue1.reload
242 assert_equal 3, issue1.status_id
243 assert_equal 90, issue1.done_ratio
244 issue2.reload
245 assert_equal 5, issue2.status_id
246 assert_equal 100, issue2.done_ratio
247 end
248 end
249
232 250 def test_update_keywords_with_multiple_rules_and_no_match
233 251 with_settings :commit_update_keywords => [
234 252 {'keywords' => 'fixes', 'status_id' => '5', 'if_tracker_id' => '2'},
235 253 {'keywords' => 'fixes', 'status_id' => '3', 'if_tracker_id' => '3'}
236 254 ] do
237 255
238 256 issue1 = Issue.generate!(:tracker_id => 2)
239 257 issue2 = Issue.generate!
240 258 Changeset.generate!(:comments => "Fixes ##{issue1.id}, ##{issue2.id}")
241 259 assert_equal 5, issue1.reload.status_id
242 260 assert_equal 1, issue2.reload.status_id # no updates
243 261 end
244 262 end
245 263
246 264 def test_commit_referencing_a_subproject_issue
247 265 c = Changeset.new(:repository => Project.find(1).repository,
248 266 :committed_on => Time.now,
249 267 :comments => 'refs #5, a subproject issue',
250 268 :revision => '12345')
251 269 assert c.save
252 270 assert_equal [5], c.issue_ids.sort
253 271 assert c.issues.first.project != c.project
254 272 end
255 273
256 274 def test_commit_closing_a_subproject_issue
257 275 with_settings :commit_update_keywords => [{'keywords' => 'closes', 'status_id' => '5'}],
258 276 :default_language => 'en' do
259 277 issue = Issue.find(5)
260 278 assert !issue.closed?
261 279 assert_difference 'Journal.count' do
262 280 c = Changeset.new(:repository => Project.find(1).repository,
263 281 :committed_on => Time.now,
264 282 :comments => 'closes #5, a subproject issue',
265 283 :revision => '12345')
266 284 assert c.save
267 285 end
268 286 assert issue.reload.closed?
269 287 journal = Journal.order('id DESC').first
270 288 assert_equal issue, journal.issue
271 289 assert_include "Applied in changeset ecookbook:r12345.", journal.notes
272 290 end
273 291 end
274 292
275 293 def test_commit_referencing_a_parent_project_issue
276 294 # repository of child project
277 295 r = Repository::Subversion.create!(
278 296 :project => Project.find(3),
279 297 :url => 'svn://localhost/test')
280 298 c = Changeset.new(:repository => r,
281 299 :committed_on => Time.now,
282 300 :comments => 'refs #2, an issue of a parent project',
283 301 :revision => '12345')
284 302 assert c.save
285 303 assert_equal [2], c.issue_ids.sort
286 304 assert c.issues.first.project != c.project
287 305 end
288 306
289 307 def test_commit_referencing_a_project_with_commit_cross_project_ref_disabled
290 308 r = Repository::Subversion.create!(
291 309 :project => Project.find(3),
292 310 :url => 'svn://localhost/test')
293 311 with_settings :commit_cross_project_ref => '0' do
294 312 c = Changeset.new(:repository => r,
295 313 :committed_on => Time.now,
296 314 :comments => 'refs #4, an issue of a different project',
297 315 :revision => '12345')
298 316 assert c.save
299 317 assert_equal [], c.issue_ids
300 318 end
301 319 end
302 320
303 321 def test_commit_referencing_a_project_with_commit_cross_project_ref_enabled
304 322 r = Repository::Subversion.create!(
305 323 :project => Project.find(3),
306 324 :url => 'svn://localhost/test')
307 325 with_settings :commit_cross_project_ref => '1' do
308 326 c = Changeset.new(:repository => r,
309 327 :committed_on => Time.now,
310 328 :comments => 'refs #4, an issue of a different project',
311 329 :revision => '12345')
312 330 assert c.save
313 331 assert_equal [4], c.issue_ids
314 332 end
315 333 end
316 334
317 335 def test_old_commits_should_not_update_issues_nor_log_time
318 336 Setting.commit_ref_keywords = '*'
319 337 Setting.commit_update_keywords = {'fixes , closes' => {'status_id' => '5', 'done_ratio' => '90'}}
320 338 Setting.commit_logtime_enabled = '1'
321 339
322 340 repository = Project.find(1).repository
323 341 repository.created_on = Time.now
324 342 repository.save!
325 343
326 344 c = Changeset.new(:repository => repository,
327 345 :committed_on => 1.month.ago,
328 346 :comments => 'New commit (#2). Fixes #1 @1h',
329 347 :revision => '12345')
330 348 assert_no_difference 'TimeEntry.count' do
331 349 assert c.save
332 350 end
333 351 assert_equal [1, 2], c.issue_ids.sort
334 352 issue = Issue.find(1)
335 353 assert_equal 1, issue.status_id
336 354 assert_equal 0, issue.done_ratio
337 355 end
338 356
339 357 def test_2_repositories_with_same_backend_should_not_link_issue_multiple_times
340 358 Setting.commit_ref_keywords = '*'
341 359 r1 = Repository::Subversion.create!(:project_id => 1, :identifier => 'svn1', :url => 'file:///svn1')
342 360 r2 = Repository::Subversion.create!(:project_id => 1, :identifier => 'svn2', :url => 'file:///svn1')
343 361 now = Time.now
344 362 assert_difference 'Issue.find(1).changesets.count' do
345 363 c1 = Changeset.create!(:repository => r1, :committed_on => now, :comments => 'Fixes #1', :revision => '12345')
346 364 c1 = Changeset.create!(:repository => r2, :committed_on => now, :comments => 'Fixes #1', :revision => '12345')
347 365 end
348 366 end
349 367
350 368 def test_text_tag_revision
351 369 c = Changeset.new(:revision => '520')
352 370 assert_equal 'r520', c.text_tag
353 371 end
354 372
355 373 def test_text_tag_revision_with_same_project
356 374 c = Changeset.new(:revision => '520', :repository => Project.find(1).repository)
357 375 assert_equal 'r520', c.text_tag(Project.find(1))
358 376 end
359 377
360 378 def test_text_tag_revision_with_different_project
361 379 c = Changeset.new(:revision => '520', :repository => Project.find(1).repository)
362 380 assert_equal 'ecookbook:r520', c.text_tag(Project.find(2))
363 381 end
364 382
365 383 def test_text_tag_revision_with_repository_identifier
366 384 r = Repository::Subversion.create!(
367 385 :project_id => 1,
368 386 :url => 'svn://localhost/test',
369 387 :identifier => 'documents')
370 388 c = Changeset.new(:revision => '520', :repository => r)
371 389 assert_equal 'documents|r520', c.text_tag
372 390 assert_equal 'ecookbook:documents|r520', c.text_tag(Project.find(2))
373 391 end
374 392
375 393 def test_text_tag_hash
376 394 c = Changeset.new(
377 395 :scmid => '7234cb2750b63f47bff735edc50a1c0a433c2518',
378 396 :revision => '7234cb2750b63f47bff735edc50a1c0a433c2518')
379 397 assert_equal 'commit:7234cb2750b63f47bff735edc50a1c0a433c2518', c.text_tag
380 398 end
381 399
382 400 def test_text_tag_hash_with_same_project
383 401 c = Changeset.new(:revision => '7234cb27', :scmid => '7234cb27', :repository => Project.find(1).repository)
384 402 assert_equal 'commit:7234cb27', c.text_tag(Project.find(1))
385 403 end
386 404
387 405 def test_text_tag_hash_with_different_project
388 406 c = Changeset.new(:revision => '7234cb27', :scmid => '7234cb27', :repository => Project.find(1).repository)
389 407 assert_equal 'ecookbook:commit:7234cb27', c.text_tag(Project.find(2))
390 408 end
391 409
392 410 def test_text_tag_hash_all_number
393 411 c = Changeset.new(:scmid => '0123456789', :revision => '0123456789')
394 412 assert_equal 'commit:0123456789', c.text_tag
395 413 end
396 414
397 415 def test_text_tag_hash_with_repository_identifier
398 416 r = Repository::Subversion.new(
399 417 :project_id => 1,
400 418 :url => 'svn://localhost/test',
401 419 :identifier => 'documents')
402 420 c = Changeset.new(:revision => '7234cb27', :scmid => '7234cb27', :repository => r)
403 421 assert_equal 'commit:documents|7234cb27', c.text_tag
404 422 assert_equal 'ecookbook:commit:documents|7234cb27', c.text_tag(Project.find(2))
405 423 end
406 424
407 425 def test_previous
408 426 changeset = Changeset.find_by_revision('3')
409 427 assert_equal Changeset.find_by_revision('2'), changeset.previous
410 428 end
411 429
412 430 def test_previous_nil
413 431 changeset = Changeset.find_by_revision('1')
414 432 assert_nil changeset.previous
415 433 end
416 434
417 435 def test_next
418 436 changeset = Changeset.find_by_revision('2')
419 437 assert_equal Changeset.find_by_revision('3'), changeset.next
420 438 end
421 439
422 440 def test_next_nil
423 441 changeset = Changeset.find_by_revision('10')
424 442 assert_nil changeset.next
425 443 end
426 444
427 445 def test_comments_should_be_converted_to_utf8
428 446 proj = Project.find(3)
429 447 # str = File.read("#{RAILS_ROOT}/test/fixtures/encoding/iso-8859-1.txt")
430 448 str = "Texte encod\xe9 en ISO-8859-1.".force_encoding("ASCII-8BIT")
431 449 r = Repository::Bazaar.create!(
432 450 :project => proj,
433 451 :url => '/tmp/test/bazaar',
434 452 :log_encoding => 'ISO-8859-1' )
435 453 assert r
436 454 c = Changeset.new(:repository => r,
437 455 :committed_on => Time.now,
438 456 :revision => '123',
439 457 :scmid => '12345',
440 458 :comments => str)
441 459 assert( c.save )
442 460 str_utf8 = "Texte encod\xc3\xa9 en ISO-8859-1.".force_encoding("UTF-8")
443 461 assert_equal str_utf8, c.comments
444 462 end
445 463
446 464 def test_invalid_utf8_sequences_in_comments_should_be_replaced_latin1
447 465 proj = Project.find(3)
448 466 # str = File.read("#{RAILS_ROOT}/test/fixtures/encoding/iso-8859-1.txt")
449 467 str1 = "Texte encod\xe9 en ISO-8859-1.".force_encoding("UTF-8")
450 468 str2 = "\xe9a\xe9b\xe9c\xe9d\xe9e test".force_encoding("ASCII-8BIT")
451 469 r = Repository::Bazaar.create!(
452 470 :project => proj,
453 471 :url => '/tmp/test/bazaar',
454 472 :log_encoding => 'UTF-8' )
455 473 assert r
456 474 c = Changeset.new(:repository => r,
457 475 :committed_on => Time.now,
458 476 :revision => '123',
459 477 :scmid => '12345',
460 478 :comments => str1,
461 479 :committer => str2)
462 480 assert( c.save )
463 481 assert_equal "Texte encod? en ISO-8859-1.", c.comments
464 482 assert_equal "?a?b?c?d?e test", c.committer
465 483 end
466 484
467 485 def test_invalid_utf8_sequences_in_comments_should_be_replaced_ja_jis
468 486 proj = Project.find(3)
469 487 str = "test\xb5\xfetest\xb5\xfe".force_encoding('ASCII-8BIT')
470 488 r = Repository::Bazaar.create!(
471 489 :project => proj,
472 490 :url => '/tmp/test/bazaar',
473 491 :log_encoding => 'ISO-2022-JP' )
474 492 assert r
475 493 c = Changeset.new(:repository => r,
476 494 :committed_on => Time.now,
477 495 :revision => '123',
478 496 :scmid => '12345',
479 497 :comments => str)
480 498 assert( c.save )
481 499 assert_equal "test??test??", c.comments
482 500 end
483 501
484 502 def test_comments_should_be_converted_all_latin1_to_utf8
485 503 s1 = "\xC2\x80"
486 504 s2 = "\xc3\x82\xc2\x80"
487 505 s4 = s2.dup
488 506 s3 = s1.dup
489 507 s1.force_encoding('ASCII-8BIT')
490 508 s2.force_encoding('ASCII-8BIT')
491 509 s3.force_encoding('ISO-8859-1')
492 510 s4.force_encoding('UTF-8')
493 511 assert_equal s3.encode('UTF-8'), s4
494 512 proj = Project.find(3)
495 513 r = Repository::Bazaar.create!(
496 514 :project => proj,
497 515 :url => '/tmp/test/bazaar',
498 516 :log_encoding => 'ISO-8859-1' )
499 517 assert r
500 518 c = Changeset.new(:repository => r,
501 519 :committed_on => Time.now,
502 520 :revision => '123',
503 521 :scmid => '12345',
504 522 :comments => s1)
505 523 assert( c.save )
506 524 assert_equal s4, c.comments
507 525 end
508 526
509 527 def test_invalid_utf8_sequences_in_paths_should_be_replaced
510 528 proj = Project.find(3)
511 529 str1 = "Texte encod\xe9 en ISO-8859-1".force_encoding("UTF-8")
512 530 str2 = "\xe9a\xe9b\xe9c\xe9d\xe9e test".force_encoding("ASCII-8BIT")
513 531 r = Repository::Bazaar.create!(
514 532 :project => proj,
515 533 :url => '/tmp/test/bazaar',
516 534 :log_encoding => 'UTF-8' )
517 535 assert r
518 536 cs = Changeset.new(
519 537 :repository => r,
520 538 :committed_on => Time.now,
521 539 :revision => '123',
522 540 :scmid => '12345',
523 541 :comments => "test")
524 542 assert(cs.save)
525 543 ch = Change.new(
526 544 :changeset => cs,
527 545 :action => "A",
528 546 :path => str1,
529 547 :from_path => str2,
530 548 :from_revision => "345")
531 549 assert(ch.save)
532 550 assert_equal "Texte encod? en ISO-8859-1", ch.path
533 551 assert_equal "?a?b?c?d?e test", ch.from_path
534 552 end
535 553
536 554 def test_comments_nil
537 555 proj = Project.find(3)
538 556 r = Repository::Bazaar.create!(
539 557 :project => proj,
540 558 :url => '/tmp/test/bazaar',
541 559 :log_encoding => 'ISO-8859-1' )
542 560 assert r
543 561 c = Changeset.new(:repository => r,
544 562 :committed_on => Time.now,
545 563 :revision => '123',
546 564 :scmid => '12345',
547 565 :comments => nil,
548 566 :committer => nil)
549 567 assert( c.save )
550 568 assert_equal "", c.comments
551 569 assert_equal nil, c.committer
552 570 assert_equal "UTF-8", c.comments.encoding.to_s
553 571 end
554 572
555 573 def test_comments_empty
556 574 proj = Project.find(3)
557 575 r = Repository::Bazaar.create!(
558 576 :project => proj,
559 577 :url => '/tmp/test/bazaar',
560 578 :log_encoding => 'ISO-8859-1' )
561 579 assert r
562 580 c = Changeset.new(:repository => r,
563 581 :committed_on => Time.now,
564 582 :revision => '123',
565 583 :scmid => '12345',
566 584 :comments => "",
567 585 :committer => "")
568 586 assert( c.save )
569 587 assert_equal "", c.comments
570 588 assert_equal "", c.committer
571 589 assert_equal "UTF-8", c.comments.encoding.to_s
572 590 assert_equal "UTF-8", c.committer.encoding.to_s
573 591 end
574 592
575 593 def test_comments_should_accept_more_than_64k
576 594 c = Changeset.new(:repository => Repository.first,
577 595 :committed_on => Time.now,
578 596 :revision => '123',
579 597 :scmid => '12345',
580 598 :comments => "a" * 500.kilobyte)
581 599 assert c.save
582 600 c.reload
583 601 assert_equal 500.kilobyte, c.comments.size
584 602 end
585 603
586 604 def test_identifier
587 605 c = Changeset.find_by_revision('1')
588 606 assert_equal c.revision, c.identifier
589 607 end
590 608 end
General Comments 0
You need to be logged in to leave comments. Login now