|
@@
-522,7
+522,8
class IssueTest < ActiveSupport::TestCase
|
|
522
|
|
|
522
|
|
|
523
|
def test_move_to_another_project_with_same_category
|
|
523
|
def test_move_to_another_project_with_same_category
|
|
524
|
issue = Issue.find(1)
|
|
524
|
issue = Issue.find(1)
|
|
525
|
assert issue.move_to_project(Project.find(2))
|
|
525
|
issue.project = Project.find(2)
|
|
|
|
|
526
|
assert issue.save
|
|
526
|
issue.reload
|
|
527
|
issue.reload
|
|
527
|
assert_equal 2, issue.project_id
|
|
528
|
assert_equal 2, issue.project_id
|
|
528
|
# Category changes
|
|
529
|
# Category changes
|
|
@@
-533,7
+534,8
class IssueTest < ActiveSupport::TestCase
|
|
533
|
|
|
534
|
|
|
534
|
def test_move_to_another_project_without_same_category
|
|
535
|
def test_move_to_another_project_without_same_category
|
|
535
|
issue = Issue.find(2)
|
|
536
|
issue = Issue.find(2)
|
|
536
|
assert issue.move_to_project(Project.find(2))
|
|
537
|
issue.project = Project.find(2)
|
|
|
|
|
538
|
assert issue.save
|
|
537
|
issue.reload
|
|
539
|
issue.reload
|
|
538
|
assert_equal 2, issue.project_id
|
|
540
|
assert_equal 2, issue.project_id
|
|
539
|
# Category cleared
|
|
541
|
# Category cleared
|
|
@@
-543,7
+545,8
class IssueTest < ActiveSupport::TestCase
|
|
543
|
def test_move_to_another_project_should_clear_fixed_version_when_not_shared
|
|
545
|
def test_move_to_another_project_should_clear_fixed_version_when_not_shared
|
|
544
|
issue = Issue.find(1)
|
|
546
|
issue = Issue.find(1)
|
|
545
|
issue.update_attribute(:fixed_version_id, 1)
|
|
547
|
issue.update_attribute(:fixed_version_id, 1)
|
|
546
|
assert issue.move_to_project(Project.find(2))
|
|
548
|
issue.project = Project.find(2)
|
|
|
|
|
549
|
assert issue.save
|
|
547
|
issue.reload
|
|
550
|
issue.reload
|
|
548
|
assert_equal 2, issue.project_id
|
|
551
|
assert_equal 2, issue.project_id
|
|
549
|
# Cleared fixed_version
|
|
552
|
# Cleared fixed_version
|
|
@@
-553,7
+556,8
class IssueTest < ActiveSupport::TestCase
|
|
553
|
def test_move_to_another_project_should_keep_fixed_version_when_shared_with_the_target_project
|
|
556
|
def test_move_to_another_project_should_keep_fixed_version_when_shared_with_the_target_project
|
|
554
|
issue = Issue.find(1)
|
|
557
|
issue = Issue.find(1)
|
|
555
|
issue.update_attribute(:fixed_version_id, 4)
|
|
558
|
issue.update_attribute(:fixed_version_id, 4)
|
|
556
|
assert issue.move_to_project(Project.find(5))
|
|
559
|
issue.project = Project.find(5)
|
|
|
|
|
560
|
assert issue.save
|
|
557
|
issue.reload
|
|
561
|
issue.reload
|
|
558
|
assert_equal 5, issue.project_id
|
|
562
|
assert_equal 5, issue.project_id
|
|
559
|
# Keep fixed_version
|
|
563
|
# Keep fixed_version
|
|
@@
-563,7
+567,8
class IssueTest < ActiveSupport::TestCase
|
|
563
|
def test_move_to_another_project_should_clear_fixed_version_when_not_shared_with_the_target_project
|
|
567
|
def test_move_to_another_project_should_clear_fixed_version_when_not_shared_with_the_target_project
|
|
564
|
issue = Issue.find(1)
|
|
568
|
issue = Issue.find(1)
|
|
565
|
issue.update_attribute(:fixed_version_id, 1)
|
|
569
|
issue.update_attribute(:fixed_version_id, 1)
|
|
566
|
assert issue.move_to_project(Project.find(5))
|
|
570
|
issue.project = Project.find(5)
|
|
|
|
|
571
|
assert issue.save
|
|
567
|
issue.reload
|
|
572
|
issue.reload
|
|
568
|
assert_equal 5, issue.project_id
|
|
573
|
assert_equal 5, issue.project_id
|
|
569
|
# Cleared fixed_version
|
|
574
|
# Cleared fixed_version
|
|
@@
-573,7
+578,8
class IssueTest < ActiveSupport::TestCase
|
|
573
|
def test_move_to_another_project_should_keep_fixed_version_when_shared_systemwide
|
|
578
|
def test_move_to_another_project_should_keep_fixed_version_when_shared_systemwide
|
|
574
|
issue = Issue.find(1)
|
|
579
|
issue = Issue.find(1)
|
|
575
|
issue.update_attribute(:fixed_version_id, 7)
|
|
580
|
issue.update_attribute(:fixed_version_id, 7)
|
|
576
|
assert issue.move_to_project(Project.find(2))
|
|
581
|
issue.project = Project.find(2)
|
|
|
|
|
582
|
assert issue.save
|
|
577
|
issue.reload
|
|
583
|
issue.reload
|
|
578
|
assert_equal 2, issue.project_id
|
|
584
|
assert_equal 2, issue.project_id
|
|
579
|
# Keep fixed_version
|
|
585
|
# Keep fixed_version
|
|
@@
-585,16
+591,18
class IssueTest < ActiveSupport::TestCase
|
|
585
|
target = Project.find(2)
|
|
591
|
target = Project.find(2)
|
|
586
|
target.tracker_ids = [3]
|
|
592
|
target.tracker_ids = [3]
|
|
587
|
target.save
|
|
593
|
target.save
|
|
588
|
assert_equal false, issue.move_to_project(target)
|
|
594
|
issue.project = target
|
|
|
|
|
595
|
assert issue.save
|
|
589
|
issue.reload
|
|
596
|
issue.reload
|
|
590
|
assert_equal 1, issue.project_id
|
|
597
|
assert_equal 2, issue.project_id
|
|
|
|
|
598
|
assert_equal 3, issue.tracker_id
|
|
591
|
end
|
|
599
|
end
|
|
592
|
|
|
600
|
|
|
593
|
def test_copy_to_the_same_project
|
|
601
|
def test_copy_to_the_same_project
|
|
594
|
issue = Issue.find(1)
|
|
602
|
issue = Issue.find(1)
|
|
595
|
copy = nil
|
|
603
|
copy = issue.copy
|
|
596
|
assert_difference 'Issue.count' do
|
|
604
|
assert_difference 'Issue.count' do
|
|
597
|
copy = issue.move_to_project(issue.project, nil, :copy => true)
|
|
605
|
copy.save!
|
|
598
|
end
|
|
606
|
end
|
|
599
|
assert_kind_of Issue, copy
|
|
607
|
assert_kind_of Issue, copy
|
|
600
|
assert_equal issue.project, copy.project
|
|
608
|
assert_equal issue.project, copy.project
|
|
@@
-603,9
+611,9
class IssueTest < ActiveSupport::TestCase
|
|
603
|
|
|
611
|
|
|
604
|
def test_copy_to_another_project_and_tracker
|
|
612
|
def test_copy_to_another_project_and_tracker
|
|
605
|
issue = Issue.find(1)
|
|
613
|
issue = Issue.find(1)
|
|
606
|
copy = nil
|
|
614
|
copy = issue.copy(:project_id => 3, :tracker_id => 2)
|
|
607
|
assert_difference 'Issue.count' do
|
|
615
|
assert_difference 'Issue.count' do
|
|
608
|
copy = issue.move_to_project(Project.find(3), Tracker.find(2), :copy => true)
|
|
616
|
copy.save!
|
|
609
|
end
|
|
617
|
end
|
|
610
|
copy.reload
|
|
618
|
copy.reload
|
|
611
|
assert_kind_of Issue, copy
|
|
619
|
assert_kind_of Issue, copy
|
|
@@
-615,66
+623,64
class IssueTest < ActiveSupport::TestCase
|
|
615
|
assert_nil copy.custom_value_for(2)
|
|
623
|
assert_nil copy.custom_value_for(2)
|
|
616
|
end
|
|
624
|
end
|
|
617
|
|
|
625
|
|
|
618
|
context "#move_to_project" do
|
|
626
|
context "#copy" do
|
|
619
|
context "as a copy" do
|
|
|
|
|
620
|
setup do
|
|
627
|
setup do
|
|
621
|
@issue = Issue.find(1)
|
|
628
|
@issue = Issue.find(1)
|
|
622
|
@copy = nil
|
|
|
|
|
623
|
end
|
|
629
|
end
|
|
624
|
|
|
630
|
|
|
625
|
should "not create a journal" do
|
|
631
|
should "not create a journal" do
|
|
626
|
@copy = @issue.move_to_project(Project.find(3), Tracker.find(2), {:copy => true, :attributes => {:assigned_to_id => 3}})
|
|
632
|
copy = @issue.copy(:project_id => 3, :tracker_id => 2, :assigned_to_id => 3)
|
|
627
|
assert_equal 0, @copy.reload.journals.size
|
|
633
|
copy.save!
|
|
|
|
|
634
|
assert_equal 0, copy.reload.journals.size
|
|
628
|
end
|
|
635
|
end
|
|
629
|
|
|
636
|
|
|
630
|
should "allow assigned_to changes" do
|
|
637
|
should "allow assigned_to changes" do
|
|
631
|
@copy = @issue.move_to_project(Project.find(3), Tracker.find(2), {:copy => true, :attributes => {:assigned_to_id => 3}})
|
|
638
|
copy = @issue.copy(:project_id => 3, :tracker_id => 2, :assigned_to_id => 3)
|
|
632
|
assert_equal 3, @copy.assigned_to_id
|
|
639
|
assert_equal 3, copy.assigned_to_id
|
|
633
|
end
|
|
640
|
end
|
|
634
|
|
|
641
|
|
|
635
|
should "allow status changes" do
|
|
642
|
should "allow status changes" do
|
|
636
|
@copy = @issue.move_to_project(Project.find(3), Tracker.find(2), {:copy => true, :attributes => {:status_id => 2}})
|
|
643
|
copy = @issue.copy(:project_id => 3, :tracker_id => 2, :status_id => 2)
|
|
637
|
assert_equal 2, @copy.status_id
|
|
644
|
assert_equal 2, copy.status_id
|
|
638
|
end
|
|
645
|
end
|
|
639
|
|
|
646
|
|
|
640
|
should "allow start date changes" do
|
|
647
|
should "allow start date changes" do
|
|
641
|
date = Date.today
|
|
648
|
date = Date.today
|
|
642
|
@copy = @issue.move_to_project(Project.find(3), Tracker.find(2), {:copy => true, :attributes => {:start_date => date}})
|
|
649
|
copy = @issue.copy(:project_id => 3, :tracker_id => 2, :start_date => date)
|
|
643
|
assert_equal date, @copy.start_date
|
|
650
|
assert_equal date, copy.start_date
|
|
644
|
end
|
|
651
|
end
|
|
645
|
|
|
652
|
|
|
646
|
should "allow due date changes" do
|
|
653
|
should "allow due date changes" do
|
|
647
|
date = Date.today
|
|
654
|
date = Date.today
|
|
648
|
@copy = @issue.move_to_project(Project.find(3), Tracker.find(2), {:copy => true, :attributes => {:due_date => date}})
|
|
655
|
copy = @issue.copy(:project_id => 3, :tracker_id => 2, :due_date => date)
|
|
649
|
|
|
656
|
assert_equal date, copy.due_date
|
|
650
|
assert_equal date, @copy.due_date
|
|
|
|
|
651
|
end
|
|
657
|
end
|
|
652
|
|
|
658
|
|
|
653
|
should "set current user as author" do
|
|
659
|
should "set current user as author" do
|
|
654
|
User.current = User.find(9)
|
|
660
|
User.current = User.find(9)
|
|
655
|
@copy = @issue.move_to_project(Project.find(3), Tracker.find(2), {:copy => true, :attributes => {}})
|
|
661
|
copy = @issue.copy(:project_id => 3, :tracker_id => 2)
|
|
656
|
|
|
662
|
assert_equal User.current, copy.author
|
|
657
|
assert_equal User.current, @copy.author
|
|
|
|
|
658
|
end
|
|
663
|
end
|
|
659
|
|
|
664
|
|
|
660
|
should "create a journal with notes" do
|
|
665
|
should "create a journal with notes" do
|
|
661
|
date = Date.today
|
|
666
|
date = Date.today
|
|
662
|
notes = "Notes added when copying"
|
|
667
|
notes = "Notes added when copying"
|
|
663
|
@copy = @issue.move_to_project(Project.find(3), Tracker.find(2), {:copy => true, :notes => notes, :attributes => {:start_date => date}})
|
|
668
|
copy = @issue.copy(:project_id => 3, :tracker_id => 2, :start_date => date)
|
|
|
|
|
669
|
copy.init_journal(User.current, notes)
|
|
|
|
|
670
|
copy.save!
|
|
664
|
|
|
671
|
|
|
665
|
assert_equal 1, @copy.journals.size
|
|
672
|
assert_equal 1, copy.journals.size
|
|
666
|
journal = @copy.journals.first
|
|
673
|
journal = copy.journals.first
|
|
667
|
assert_equal 0, journal.details.size
|
|
674
|
assert_equal 0, journal.details.size
|
|
668
|
assert_equal notes, journal.notes
|
|
675
|
assert_equal notes, journal.notes
|
|
669
|
end
|
|
676
|
end
|
|
670
|
end
|
|
677
|
end
|
|
671
|
end
|
|
|
|
|
672
|
|
|
678
|
|
|
673
|
def test_recipients_should_not_include_users_that_cannot_view_the_issue
|
|
679
|
def test_recipients_should_not_include_users_that_cannot_view_the_issue
|
|
674
|
issue = Issue.find(12)
|
|
680
|
issue = Issue.find(12)
|
|
675
|
assert issue.recipients.include?(issue.author.mail)
|
|
681
|
assert issue.recipients.include?(issue.author.mail)
|
|
676
|
# move the issue to a private project
|
|
682
|
# copy the issue to a private project
|
|
677
|
copy = issue.move_to_project(Project.find(5), Tracker.find(2), :copy => true)
|
|
683
|
copy = issue.copy(:project_id => 5, :tracker_id => 2)
|
|
678
|
# author is not a member of project anymore
|
|
684
|
# author is not a member of project anymore
|
|
679
|
assert !copy.recipients.include?(copy.author.mail)
|
|
685
|
assert !copy.recipients.include?(copy.author.mail)
|
|
680
|
end
|
|
686
|
end
|