##// END OF EJS Templates
remove trailing white-spaces and empty lines from unit issue test....
Toshi MARUYAMA -
r5686:de13c0007bb7
parent child
Show More
@@ -5,12 +5,12
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.
@@ -22,7 +22,7 class IssueTest < ActiveSupport::TestCase
22 22 :trackers, :projects_trackers,
23 23 :enabled_modules,
24 24 :versions,
25 :issue_statuses, :issue_categories, :issue_relations, :workflows,
25 :issue_statuses, :issue_categories, :issue_relations, :workflows,
26 26 :enumerations,
27 27 :issues,
28 28 :custom_fields, :custom_fields_projects, :custom_fields_trackers, :custom_values,
@@ -34,17 +34,17 class IssueTest < ActiveSupport::TestCase
34 34 issue.reload
35 35 assert_equal 1.5, issue.estimated_hours
36 36 end
37
37
38 38 def test_create_minimal
39 39 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3, :status_id => 1, :priority => IssuePriority.all.first, :subject => 'test_create')
40 40 assert issue.save
41 41 assert issue.description.nil?
42 42 end
43
43
44 44 def test_create_with_required_custom_field
45 45 field = IssueCustomField.find_by_name('Database')
46 46 field.update_attribute(:is_required, true)
47
47
48 48 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :subject => 'test_create', :description => 'IssueTest#test_create_with_required_custom_field')
49 49 assert issue.available_custom_fields.include?(field)
50 50 # No value for the custom field
@@ -64,7 +64,7 class IssueTest < ActiveSupport::TestCase
64 64 issue.reload
65 65 assert_equal 'PostgreSQL', issue.custom_value_for(field).value
66 66 end
67
67
68 68 def assert_visibility_match(user, issues)
69 69 assert_equal issues.collect(&:id).sort, Issue.all.select {|issue| issue.visible?(user)}.collect(&:id).sort
70 70 end
@@ -77,17 +77,17 class IssueTest < ActiveSupport::TestCase
77 77 assert_nil issues.detect {|issue| issue.is_private?}
78 78 assert_visibility_match User.anonymous, issues
79 79 end
80
80
81 81 def test_visible_scope_for_anonymous_with_own_issues_visibility
82 82 Role.anonymous.update_attribute :issues_visibility, 'own'
83 83 Issue.create!(:project_id => 1, :tracker_id => 1, :author_id => User.anonymous.id, :subject => 'Issue by anonymous')
84
84
85 85 issues = Issue.visible(User.anonymous).all
86 86 assert issues.any?
87 87 assert_nil issues.detect {|issue| issue.author != User.anonymous}
88 88 assert_visibility_match User.anonymous, issues
89 89 end
90
90
91 91 def test_visible_scope_for_anonymous_without_view_issues_permissions
92 92 # Anonymous user should not see issues without permission
93 93 Role.anonymous.remove_permission!(:view_issues)
@@ -95,7 +95,7 class IssueTest < ActiveSupport::TestCase
95 95 assert issues.empty?
96 96 assert_visibility_match User.anonymous, issues
97 97 end
98
98
99 99 def test_visible_scope_for_non_member
100 100 user = User.find(9)
101 101 assert user.projects.empty?
@@ -106,18 +106,18 class IssueTest < ActiveSupport::TestCase
106 106 assert_nil issues.detect {|issue| issue.is_private?}
107 107 assert_visibility_match user, issues
108 108 end
109
109
110 110 def test_visible_scope_for_non_member_with_own_issues_visibility
111 111 Role.non_member.update_attribute :issues_visibility, 'own'
112 112 Issue.create!(:project_id => 1, :tracker_id => 1, :author_id => 9, :subject => 'Issue by non member')
113 113 user = User.find(9)
114
114
115 115 issues = Issue.visible(user).all
116 116 assert issues.any?
117 117 assert_nil issues.detect {|issue| issue.author != user}
118 118 assert_visibility_match user, issues
119 119 end
120
120
121 121 def test_visible_scope_for_non_member_without_view_issues_permissions
122 122 # Non member user should not see issues without permission
123 123 Role.non_member.remove_permission!(:view_issues)
@@ -127,7 +127,7 class IssueTest < ActiveSupport::TestCase
127 127 assert issues.empty?
128 128 assert_visibility_match user, issues
129 129 end
130
130
131 131 def test_visible_scope_for_member
132 132 user = User.find(9)
133 133 # User should see issues of projects for which he has view_issues permissions only
@@ -139,7 +139,7 class IssueTest < ActiveSupport::TestCase
139 139 assert_nil issues.detect {|issue| issue.is_private?}
140 140 assert_visibility_match user, issues
141 141 end
142
142
143 143 def test_visible_scope_for_admin
144 144 user = User.find(1)
145 145 user.members.each(&:destroy)
@@ -152,7 +152,7 class IssueTest < ActiveSupport::TestCase
152 152 assert issues.detect {|issue| issue.is_private? && issue.author != user}
153 153 assert_visibility_match user, issues
154 154 end
155
155
156 156 def test_visible_scope_with_project
157 157 project = Project.find(1)
158 158 issues = Issue.visible(User.find(2), :project => project).all
@@ -160,7 +160,7 class IssueTest < ActiveSupport::TestCase
160 160 assert_equal 1, projects.size
161 161 assert_equal project, projects.first
162 162 end
163
163
164 164 def test_visible_scope_with_project_and_subprojects
165 165 project = Project.find(1)
166 166 issues = Issue.visible(User.find(2), :project => project, :with_subprojects => true).all
@@ -168,28 +168,28 class IssueTest < ActiveSupport::TestCase
168 168 assert projects.size > 1
169 169 assert_equal [], projects.select {|p| !p.is_or_is_descendant_of?(project)}
170 170 end
171
171
172 172 def test_visible_and_nested_set_scopes
173 173 assert_equal 0, Issue.find(1).descendants.visible.all.size
174 174 end
175
175
176 176 def test_errors_full_messages_should_include_custom_fields_errors
177 177 field = IssueCustomField.find_by_name('Database')
178
178
179 179 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :subject => 'test_create', :description => 'IssueTest#test_create_with_required_custom_field')
180 180 assert issue.available_custom_fields.include?(field)
181 181 # Invalid value
182 182 issue.custom_field_values = { field.id => 'SQLServer' }
183
183
184 184 assert !issue.valid?
185 185 assert_equal 1, issue.errors.full_messages.size
186 186 assert_equal "Database #{I18n.translate('activerecord.errors.messages.inclusion')}", issue.errors.full_messages.first
187 187 end
188
188
189 189 def test_update_issue_with_required_custom_field
190 190 field = IssueCustomField.find_by_name('Database')
191 191 field.update_attribute(:is_required, true)
192
192
193 193 issue = Issue.find(1)
194 194 assert_nil issue.custom_value_for(field)
195 195 assert issue.available_custom_fields.include?(field)
@@ -204,23 +204,23 class IssueTest < ActiveSupport::TestCase
204 204 issue.reload
205 205 assert_equal 'PostgreSQL', issue.custom_value_for(field).value
206 206 end
207
207
208 208 def test_should_not_update_attributes_if_custom_fields_validation_fails
209 209 issue = Issue.find(1)
210 210 field = IssueCustomField.find_by_name('Database')
211 211 assert issue.available_custom_fields.include?(field)
212
212
213 213 issue.custom_field_values = { field.id => 'Invalid' }
214 214 issue.subject = 'Should be not be saved'
215 215 assert !issue.save
216
216
217 217 issue.reload
218 218 assert_equal "Can't print recipes", issue.subject
219 219 end
220
220
221 221 def test_should_not_recreate_custom_values_objects_on_update
222 222 field = IssueCustomField.find_by_name('Database')
223
223
224 224 issue = Issue.find(1)
225 225 issue.custom_field_values = { field.id => 'PostgreSQL' }
226 226 assert issue.save
@@ -231,14 +231,14 class IssueTest < ActiveSupport::TestCase
231 231 issue.reload
232 232 assert_equal custom_value.id, issue.custom_value_for(field).id
233 233 end
234
234
235 235 def test_assigning_tracker_id_should_reload_custom_fields_values
236 236 issue = Issue.new(:project => Project.find(1))
237 237 assert issue.custom_field_values.empty?
238 238 issue.tracker_id = 1
239 239 assert issue.custom_field_values.any?
240 240 end
241
241
242 242 def test_assigning_attributes_should_assign_tracker_id_first
243 243 attributes = ActiveSupport::OrderedHash.new
244 244 attributes['custom_field_values'] = { '1' => 'MySQL' }
@@ -248,40 +248,38 class IssueTest < ActiveSupport::TestCase
248 248 assert_not_nil issue.custom_value_for(1)
249 249 assert_equal 'MySQL', issue.custom_value_for(1).value
250 250 end
251
251
252 252 def test_should_update_issue_with_disabled_tracker
253 253 p = Project.find(1)
254 254 issue = Issue.find(1)
255
255
256 256 p.trackers.delete(issue.tracker)
257 257 assert !p.trackers.include?(issue.tracker)
258
258
259 259 issue.reload
260 260 issue.subject = 'New subject'
261 261 assert issue.save
262 262 end
263
263
264 264 def test_should_not_set_a_disabled_tracker
265 265 p = Project.find(1)
266 266 p.trackers.delete(Tracker.find(2))
267
267
268 268 issue = Issue.find(1)
269 269 issue.tracker_id = 2
270 270 issue.subject = 'New subject'
271 271 assert !issue.save
272 272 assert_not_nil issue.errors.on(:tracker_id)
273 273 end
274
274
275 275 def test_category_based_assignment
276 276 issue = Issue.create(:project_id => 1, :tracker_id => 1, :author_id => 3, :status_id => 1, :priority => IssuePriority.all.first, :subject => 'Assignment test', :description => 'Assignment test', :category_id => 1)
277 277 assert_equal IssueCategory.find(1).assigned_to, issue.assigned_to
278 278 end
279
280
281
279
282 280 def test_new_statuses_allowed_to
283 281 Workflow.delete_all
284
282
285 283 Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 2, :author => false, :assignee => false)
286 284 Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 3, :author => true, :assignee => false)
287 285 Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 4, :author => false, :assignee => true)
@@ -290,20 +288,20 class IssueTest < ActiveSupport::TestCase
290 288 role = Role.find(1)
291 289 tracker = Tracker.find(1)
292 290 user = User.find(2)
293
291
294 292 issue = Issue.generate!(:tracker => tracker, :status => status, :project_id => 1)
295 293 assert_equal [1, 2], issue.new_statuses_allowed_to(user).map(&:id)
296
294
297 295 issue = Issue.generate!(:tracker => tracker, :status => status, :project_id => 1, :author => user)
298 296 assert_equal [1, 2, 3], issue.new_statuses_allowed_to(user).map(&:id)
299
297
300 298 issue = Issue.generate!(:tracker => tracker, :status => status, :project_id => 1, :assigned_to => user)
301 299 assert_equal [1, 2, 4], issue.new_statuses_allowed_to(user).map(&:id)
302
300
303 301 issue = Issue.generate!(:tracker => tracker, :status => status, :project_id => 1, :author => user, :assigned_to => user)
304 302 assert_equal [1, 2, 3, 4, 5], issue.new_statuses_allowed_to(user).map(&:id)
305 303 end
306
304
307 305 def test_copy
308 306 issue = Issue.new.copy_from(1)
309 307 assert issue.save
@@ -317,13 +315,13 class IssueTest < ActiveSupport::TestCase
317 315 def test_copy_should_copy_status
318 316 orig = Issue.find(8)
319 317 assert orig.status != IssueStatus.default
320
318
321 319 issue = Issue.new.copy_from(orig)
322 320 assert issue.save
323 321 issue.reload
324 322 assert_equal orig.status, issue.status
325 323 end
326
324
327 325 def test_should_close_duplicates
328 326 # Create 3 issues
329 327 issue1 = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :priority => IssuePriority.all.first, :subject => 'Duplicates test', :description => 'Duplicates test')
@@ -332,37 +330,37 class IssueTest < ActiveSupport::TestCase
332 330 assert issue2.save
333 331 issue3 = issue1.clone
334 332 assert issue3.save
335
333
336 334 # 2 is a dupe of 1
337 335 IssueRelation.create(:issue_from => issue2, :issue_to => issue1, :relation_type => IssueRelation::TYPE_DUPLICATES)
338 336 # And 3 is a dupe of 2
339 337 IssueRelation.create(:issue_from => issue3, :issue_to => issue2, :relation_type => IssueRelation::TYPE_DUPLICATES)
340 338 # And 3 is a dupe of 1 (circular duplicates)
341 339 IssueRelation.create(:issue_from => issue3, :issue_to => issue1, :relation_type => IssueRelation::TYPE_DUPLICATES)
342
340
343 341 assert issue1.reload.duplicates.include?(issue2)
344
342
345 343 # Closing issue 1
346 344 issue1.init_journal(User.find(:first), "Closing issue1")
347 345 issue1.status = IssueStatus.find :first, :conditions => {:is_closed => true}
348 346 assert issue1.save
349 347 # 2 and 3 should be also closed
350 348 assert issue2.reload.closed?
351 assert issue3.reload.closed?
349 assert issue3.reload.closed?
352 350 end
353
351
354 352 def test_should_not_close_duplicated_issue
355 353 # Create 3 issues
356 354 issue1 = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :priority => IssuePriority.all.first, :subject => 'Duplicates test', :description => 'Duplicates test')
357 355 assert issue1.save
358 356 issue2 = issue1.clone
359 357 assert issue2.save
360
358
361 359 # 2 is a dupe of 1
362 360 IssueRelation.create(:issue_from => issue2, :issue_to => issue1, :relation_type => IssueRelation::TYPE_DUPLICATES)
363 361 # 2 is a dup of 1 but 1 is not a duplicate of 2
364 362 assert !issue2.reload.duplicates.include?(issue1)
365
363
366 364 # Closing issue 2
367 365 issue2.init_journal(User.find(:first), "Closing issue2")
368 366 issue2.status = IssueStatus.find :first, :conditions => {:is_closed => true}
@@ -370,57 +368,57 class IssueTest < ActiveSupport::TestCase
370 368 # 1 should not be also closed
371 369 assert !issue1.reload.closed?
372 370 end
373
371
374 372 def test_assignable_versions
375 373 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :fixed_version_id => 1, :subject => 'New issue')
376 374 assert_equal ['open'], issue.assignable_versions.collect(&:status).uniq
377 375 end
378
376
379 377 def test_should_not_be_able_to_assign_a_new_issue_to_a_closed_version
380 378 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :fixed_version_id => 1, :subject => 'New issue')
381 379 assert !issue.save
382 380 assert_not_nil issue.errors.on(:fixed_version_id)
383 381 end
384
382
385 383 def test_should_not_be_able_to_assign_a_new_issue_to_a_locked_version
386 384 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :fixed_version_id => 2, :subject => 'New issue')
387 385 assert !issue.save
388 386 assert_not_nil issue.errors.on(:fixed_version_id)
389 387 end
390
388
391 389 def test_should_be_able_to_assign_a_new_issue_to_an_open_version
392 390 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :fixed_version_id => 3, :subject => 'New issue')
393 391 assert issue.save
394 392 end
395
393
396 394 def test_should_be_able_to_update_an_issue_assigned_to_a_closed_version
397 395 issue = Issue.find(11)
398 396 assert_equal 'closed', issue.fixed_version.status
399 397 issue.subject = 'Subject changed'
400 398 assert issue.save
401 399 end
402
400
403 401 def test_should_not_be_able_to_reopen_an_issue_assigned_to_a_closed_version
404 402 issue = Issue.find(11)
405 403 issue.status_id = 1
406 404 assert !issue.save
407 405 assert_not_nil issue.errors.on_base
408 406 end
409
407
410 408 def test_should_be_able_to_reopen_and_reassign_an_issue_assigned_to_a_closed_version
411 409 issue = Issue.find(11)
412 410 issue.status_id = 1
413 411 issue.fixed_version_id = 3
414 412 assert issue.save
415 413 end
416
414
417 415 def test_should_be_able_to_reopen_an_issue_assigned_to_a_locked_version
418 416 issue = Issue.find(12)
419 417 assert_equal 'locked', issue.fixed_version.status
420 418 issue.status_id = 1
421 419 assert issue.save
422 420 end
423
421
424 422 def test_move_to_another_project_with_same_category
425 423 issue = Issue.find(1)
426 424 assert issue.move_to_project(Project.find(2))
@@ -431,7 +429,7 class IssueTest < ActiveSupport::TestCase
431 429 # Make sure time entries were move to the target project
432 430 assert_equal 2, issue.time_entries.first.project_id
433 431 end
434
432
435 433 def test_move_to_another_project_without_same_category
436 434 issue = Issue.find(2)
437 435 assert issue.move_to_project(Project.find(2))
@@ -440,7 +438,7 class IssueTest < ActiveSupport::TestCase
440 438 # Category cleared
441 439 assert_nil issue.category_id
442 440 end
443
441
444 442 def test_move_to_another_project_should_clear_fixed_version_when_not_shared
445 443 issue = Issue.find(1)
446 444 issue.update_attribute(:fixed_version_id, 1)
@@ -450,7 +448,7 class IssueTest < ActiveSupport::TestCase
450 448 # Cleared fixed_version
451 449 assert_equal nil, issue.fixed_version
452 450 end
453
451
454 452 def test_move_to_another_project_should_keep_fixed_version_when_shared_with_the_target_project
455 453 issue = Issue.find(1)
456 454 issue.update_attribute(:fixed_version_id, 4)
@@ -460,7 +458,7 class IssueTest < ActiveSupport::TestCase
460 458 # Keep fixed_version
461 459 assert_equal 4, issue.fixed_version_id
462 460 end
463
461
464 462 def test_move_to_another_project_should_clear_fixed_version_when_not_shared_with_the_target_project
465 463 issue = Issue.find(1)
466 464 issue.update_attribute(:fixed_version_id, 1)
@@ -470,7 +468,7 class IssueTest < ActiveSupport::TestCase
470 468 # Cleared fixed_version
471 469 assert_equal nil, issue.fixed_version
472 470 end
473
471
474 472 def test_move_to_another_project_should_keep_fixed_version_when_shared_systemwide
475 473 issue = Issue.find(1)
476 474 issue.update_attribute(:fixed_version_id, 7)
@@ -480,7 +478,7 class IssueTest < ActiveSupport::TestCase
480 478 # Keep fixed_version
481 479 assert_equal 7, issue.fixed_version_id
482 480 end
483
481
484 482 def test_move_to_another_project_with_disabled_tracker
485 483 issue = Issue.find(1)
486 484 target = Project.find(2)
@@ -490,7 +488,7 class IssueTest < ActiveSupport::TestCase
490 488 issue.reload
491 489 assert_equal 1, issue.project_id
492 490 end
493
491
494 492 def test_copy_to_the_same_project
495 493 issue = Issue.find(1)
496 494 copy = nil
@@ -501,7 +499,7 class IssueTest < ActiveSupport::TestCase
501 499 assert_equal issue.project, copy.project
502 500 assert_equal "125", copy.custom_value_for(2).value
503 501 end
504
502
505 503 def test_copy_to_another_project_and_tracker
506 504 issue = Issue.find(1)
507 505 copy = nil
@@ -522,7 +520,7 class IssueTest < ActiveSupport::TestCase
522 520 @issue = Issue.find(1)
523 521 @copy = nil
524 522 end
525
523
526 524 should "not create a journal" do
527 525 @copy = @issue.move_to_project(Project.find(3), Tracker.find(2), {:copy => true, :attributes => {:assigned_to_id => 3}})
528 526 assert_equal 0, @copy.reload.journals.size
@@ -550,14 +548,14 class IssueTest < ActiveSupport::TestCase
550 548
551 549 assert_equal date, @copy.due_date
552 550 end
553
551
554 552 should "set current user as author" do
555 553 User.current = User.find(9)
556 554 @copy = @issue.move_to_project(Project.find(3), Tracker.find(2), {:copy => true, :attributes => {}})
557 555
558 556 assert_equal User.current, @copy.author
559 557 end
560
558
561 559 should "keep journal notes" do
562 560 date = Date.today
563 561 notes = "Notes added when copying"
@@ -572,7 +570,7 class IssueTest < ActiveSupport::TestCase
572 570 end
573 571 end
574 572 end
575
573
576 574 def test_recipients_should_not_include_users_that_cannot_view_the_issue
577 575 issue = Issue.find(12)
578 576 assert issue.recipients.include?(issue.author.mail)
@@ -589,50 +587,50 class IssueTest < ActiveSupport::TestCase
589 587 assert issue.watched_by?(user)
590 588 assert !issue.watcher_recipients.include?(user.mail)
591 589 end
592
590
593 591 def test_issue_destroy
594 592 Issue.find(1).destroy
595 593 assert_nil Issue.find_by_id(1)
596 594 assert_nil TimeEntry.find_by_issue_id(1)
597 595 end
598
596
599 597 def test_blocked
600 598 blocked_issue = Issue.find(9)
601 599 blocking_issue = Issue.find(10)
602
600
603 601 assert blocked_issue.blocked?
604 602 assert !blocking_issue.blocked?
605 603 end
606
604
607 605 def test_blocked_issues_dont_allow_closed_statuses
608 606 blocked_issue = Issue.find(9)
609
607
610 608 allowed_statuses = blocked_issue.new_statuses_allowed_to(users(:users_002))
611 609 assert !allowed_statuses.empty?
612 610 closed_statuses = allowed_statuses.select {|st| st.is_closed?}
613 611 assert closed_statuses.empty?
614 612 end
615
613
616 614 def test_unblocked_issues_allow_closed_statuses
617 615 blocking_issue = Issue.find(10)
618
616
619 617 allowed_statuses = blocking_issue.new_statuses_allowed_to(users(:users_002))
620 618 assert !allowed_statuses.empty?
621 619 closed_statuses = allowed_statuses.select {|st| st.is_closed?}
622 620 assert !closed_statuses.empty?
623 621 end
624
622
625 623 def test_rescheduling_an_issue_should_reschedule_following_issue
626 624 issue1 = Issue.create!(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :subject => '-', :start_date => Date.today, :due_date => Date.today + 2)
627 625 issue2 = Issue.create!(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :subject => '-', :start_date => Date.today, :due_date => Date.today + 2)
628 626 IssueRelation.create!(:issue_from => issue1, :issue_to => issue2, :relation_type => IssueRelation::TYPE_PRECEDES)
629 627 assert_equal issue1.due_date + 1, issue2.reload.start_date
630
628
631 629 issue1.due_date = Date.today + 5
632 630 issue1.save!
633 631 assert_equal issue1.due_date + 1, issue2.reload.start_date
634 632 end
635
633
636 634 def test_overdue
637 635 assert Issue.new(:due_date => 1.day.ago.to_date).overdue?
638 636 assert !Issue.new(:due_date => Date.today).overdue?
@@ -679,13 +677,13 class IssueTest < ActiveSupport::TestCase
679 677 should "not show the issue author twice" do
680 678 assignable_user_ids = Issue.find(1).assignable_users.collect(&:id)
681 679 assert_equal 2, assignable_user_ids.length
682
680
683 681 assignable_user_ids.each do |user_id|
684 682 assert_equal 1, assignable_user_ids.select {|i| i == user_id}.length, "User #{user_id} appears more or less than once"
685 683 end
686 684 end
687 685 end
688
686
689 687 def test_create_should_send_email_notification
690 688 ActionMailer::Base.deliveries.clear
691 689 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3, :status_id => 1, :priority => IssuePriority.all.first, :subject => 'test_create', :estimated_hours => '1:30')
@@ -698,13 +696,13 class IssueTest < ActiveSupport::TestCase
698 696 ActionMailer::Base.deliveries.clear
699 697 issue = Issue.find(1)
700 698 stale = Issue.find(1)
701
699
702 700 issue.init_journal(User.find(1))
703 701 issue.subject = 'Subjet update'
704 702 assert issue.save
705 703 assert_equal 1, ActionMailer::Base.deliveries.size
706 704 ActionMailer::Base.deliveries.clear
707
705
708 706 stale.init_journal(User.find(1))
709 707 stale.subject = 'Another subjet update'
710 708 assert_raise ActiveRecord::StaleObjectError do
@@ -712,14 +710,14 class IssueTest < ActiveSupport::TestCase
712 710 end
713 711 assert ActionMailer::Base.deliveries.empty?
714 712 end
715
713
716 714 def test_journalized_description
717 715 IssueCustomField.delete_all
718
716
719 717 i = Issue.first
720 718 old_description = i.description
721 719 new_description = "This is the new description"
722
720
723 721 i.init_journal(User.find(2))
724 722 i.description = new_description
725 723 assert_difference 'Journal.count', 1 do
@@ -727,7 +725,7 class IssueTest < ActiveSupport::TestCase
727 725 i.save!
728 726 end
729 727 end
730
728
731 729 detail = JournalDetail.first(:order => 'id DESC')
732 730 assert_equal i, detail.journal.journalized
733 731 assert_equal 'attr', detail.property
@@ -735,7 +733,7 class IssueTest < ActiveSupport::TestCase
735 733 assert_equal old_description, detail.old_value
736 734 assert_equal new_description, detail.value
737 735 end
738
736
739 737 def test_saving_twice_should_not_duplicate_journal_details
740 738 i = Issue.find(:first)
741 739 i.init_journal(User.find(2), 'Some notes')
@@ -765,7 +763,7 class IssueTest < ActiveSupport::TestCase
765 763 assert IssueRelation.create!(:issue_from => Issue.find(1), :issue_to => Issue.find(2), :relation_type => IssueRelation::TYPE_PRECEDES)
766 764 assert IssueRelation.create!(:issue_from => Issue.find(2), :issue_to => Issue.find(3), :relation_type => IssueRelation::TYPE_PRECEDES)
767 765 assert IssueRelation.create!(:issue_from => Issue.find(3), :issue_to => Issue.find(8), :relation_type => IssueRelation::TYPE_PRECEDES)
768
766
769 767 assert_equal [2, 3, 8], Issue.find(1).all_dependent_issues.collect(&:id).sort
770 768 end
771 769
@@ -775,7 +773,7 class IssueTest < ActiveSupport::TestCase
775 773 assert IssueRelation.create!(:issue_from => Issue.find(2), :issue_to => Issue.find(3), :relation_type => IssueRelation::TYPE_PRECEDES)
776 774 # Validation skipping
777 775 assert IssueRelation.new(:issue_from => Issue.find(3), :issue_to => Issue.find(1), :relation_type => IssueRelation::TYPE_PRECEDES).save(false)
778
776
779 777 assert_equal [2, 3], Issue.find(1).all_dependent_issues.collect(&:id).sort
780 778 end
781 779
@@ -787,10 +785,10 class IssueTest < ActiveSupport::TestCase
787 785 # Validation skipping
788 786 assert IssueRelation.new(:issue_from => Issue.find(8), :issue_to => Issue.find(2), :relation_type => IssueRelation::TYPE_RELATES).save(false)
789 787 assert IssueRelation.new(:issue_from => Issue.find(3), :issue_to => Issue.find(1), :relation_type => IssueRelation::TYPE_RELATES).save(false)
790
788
791 789 assert_equal [2, 3, 8], Issue.find(1).all_dependent_issues.collect(&:id).sort
792 790 end
793
791
794 792 context "#done_ratio" do
795 793 setup do
796 794 @issue = Issue.find(1)
@@ -800,12 +798,12 class IssueTest < ActiveSupport::TestCase
800 798 @issue_status2 = IssueStatus.find(2)
801 799 @issue_status2.update_attribute(:default_done_ratio, 0)
802 800 end
803
801
804 802 context "with Setting.issue_done_ratio using the issue_field" do
805 803 setup do
806 804 Setting.issue_done_ratio = 'issue_field'
807 805 end
808
806
809 807 should "read the issue's field" do
810 808 assert_equal 0, @issue.done_ratio
811 809 assert_equal 30, @issue2.done_ratio
@@ -816,7 +814,7 class IssueTest < ActiveSupport::TestCase
816 814 setup do
817 815 Setting.issue_done_ratio = 'issue_status'
818 816 end
819
817
820 818 should "read the Issue Status's default done ratio" do
821 819 assert_equal 50, @issue.done_ratio
822 820 assert_equal 0, @issue2.done_ratio
@@ -833,12 +831,12 class IssueTest < ActiveSupport::TestCase
833 831 @issue_status2 = IssueStatus.find(2)
834 832 @issue_status2.update_attribute(:default_done_ratio, 0)
835 833 end
836
834
837 835 context "with Setting.issue_done_ratio using the issue_field" do
838 836 setup do
839 837 Setting.issue_done_ratio = 'issue_field'
840 838 end
841
839
842 840 should "not change the issue" do
843 841 @issue.update_done_ratio_from_issue_status
844 842 @issue2.update_done_ratio_from_issue_status
@@ -852,7 +850,7 class IssueTest < ActiveSupport::TestCase
852 850 setup do
853 851 Setting.issue_done_ratio = 'issue_status'
854 852 end
855
853
856 854 should "change the issue's done ratio" do
857 855 @issue.update_done_ratio_from_issue_status
858 856 @issue2.update_done_ratio_from_issue_status
@@ -912,19 +910,18 class IssueTest < ActiveSupport::TestCase
912 910 assert_equal 1, groups.size
913 911 assert_equal 2, groups.inject(0) {|sum, group| sum + group['total'].to_i}
914 912 end
915
916
913
917 914 context ".allowed_target_projects_on_move" do
918 915 should "return all active projects for admin users" do
919 916 User.current = User.find(1)
920 917 assert_equal Project.active.count, Issue.allowed_target_projects_on_move.size
921 918 end
922
919
923 920 should "return allowed projects for non admin users" do
924 921 User.current = User.find(2)
925 922 Role.non_member.remove_permission! :move_issues
926 923 assert_equal 3, Issue.allowed_target_projects_on_move.size
927
924
928 925 Role.non_member.add_permission! :move_issues
929 926 assert_equal Project.active.count, Issue.allowed_target_projects_on_move.size
930 927 end
@@ -938,7 +935,7 class IssueTest < ActiveSupport::TestCase
938 935
939 936 def test_on_active_projects_scope
940 937 assert Project.find(2).archive
941
938
942 939 before = Issue.on_active_project.length
943 940 # test inclusion to results
944 941 issue = Issue.generate_for_project!(Project.find(1), :tracker => Project.find(2).trackers.first)
@@ -957,7 +954,7 class IssueTest < ActiveSupport::TestCase
957 954 @assignee = User.generate_with_protected!
958 955 @issue = Issue.generate_for_project!(@project, :assigned_to => @assignee, :author => @author)
959 956 end
960
957
961 958 should "include project recipients" do
962 959 assert @project.recipients.present?
963 960 @project.recipients.each do |project_recipient|
@@ -969,7 +966,7 class IssueTest < ActiveSupport::TestCase
969 966 assert @issue.author, "No author set for Issue"
970 967 assert @issue.recipients.include?(@issue.author.mail)
971 968 end
972
969
973 970 should "include the assigned to user if the assigned to user is active" do
974 971 assert @issue.assigned_to, "No assigned_to set for Issue"
975 972 assert @issue.recipients.include?(@issue.assigned_to.mail)
General Comments 0
You need to be logged in to leave comments. Login now