@@ -148,6 +148,7 class Issue < ActiveRecord::Base | |||
|
148 | 148 | |
|
149 | 149 | def reload(*args) |
|
150 | 150 | @workflow_rule_by_attribute = nil |
|
151 | @assignable_versions = nil | |
|
151 | 152 | super |
|
152 | 153 | end |
|
153 | 154 | |
@@ -252,6 +253,8 class Issue < ActiveRecord::Base | |||
|
252 | 253 | write_attribute(:project_id, project ? project.id : nil) |
|
253 | 254 | association_instance_set('project', project) |
|
254 | 255 | if project_was && project && project_was != project |
|
256 | @assignable_versions = nil | |
|
257 | ||
|
255 | 258 | unless keep_tracker || project.trackers.include?(tracker) |
|
256 | 259 | self.tracker = project.trackers.first |
|
257 | 260 | end |
@@ -639,7 +642,21 class Issue < ActiveRecord::Base | |||
|
639 | 642 | |
|
640 | 643 | # Versions that the issue can be assigned to |
|
641 | 644 | def assignable_versions |
|
642 | @assignable_versions ||= (project.shared_versions.open + [Version.find_by_id(fixed_version_id_was)]).compact.uniq.sort | |
|
645 | return @assignable_versions if @assignable_versions | |
|
646 | ||
|
647 | versions = project.shared_versions.open.all | |
|
648 | if fixed_version | |
|
649 | if fixed_version_id_changed? | |
|
650 | # nothing to do | |
|
651 | elsif project_id_changed? | |
|
652 | if project.shared_versions.include?(fixed_version) | |
|
653 | versions << fixed_version | |
|
654 | end | |
|
655 | else | |
|
656 | versions << fixed_version | |
|
657 | end | |
|
658 | end | |
|
659 | @assignable_versions = versions.uniq.sort | |
|
643 | 660 | end |
|
644 | 661 | |
|
645 | 662 | # Returns true if this issue is blocked by another issue that is still open |
@@ -760,6 +760,26 class IssueTest < ActiveSupport::TestCase | |||
|
760 | 760 | assert issue.save |
|
761 | 761 | end |
|
762 | 762 | |
|
763 | def test_should_not_be_able_to_keep_unshared_version_when_changing_project | |
|
764 | issue = Issue.find(2) | |
|
765 | assert_equal 2, issue.fixed_version_id | |
|
766 | issue.project_id = 3 | |
|
767 | assert_nil issue.fixed_version_id | |
|
768 | issue.fixed_version_id = 2 | |
|
769 | assert !issue.save | |
|
770 | assert_include 'Target version is not included in the list', issue.errors.full_messages | |
|
771 | end | |
|
772 | ||
|
773 | def test_should_keep_shared_version_when_changing_project | |
|
774 | Version.find(2).update_attribute :sharing, 'tree' | |
|
775 | ||
|
776 | issue = Issue.find(2) | |
|
777 | assert_equal 2, issue.fixed_version_id | |
|
778 | issue.project_id = 3 | |
|
779 | assert_equal 2, issue.fixed_version_id | |
|
780 | assert issue.save | |
|
781 | end | |
|
782 | ||
|
763 | 783 | def test_allowed_target_projects_on_move_should_include_projects_with_issue_tracking_enabled |
|
764 | 784 | assert_include Project.find(2), Issue.allowed_target_projects_on_move(User.find(2)) |
|
765 | 785 | end |
General Comments 0
You need to be logged in to leave comments.
Login now