Versions that are not shared should not be assignable when selecting another project (#11506).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10086 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
1 parent
ed165f6716
commit
9eb041fbc7
2 files changed
+38
-1
No files matched your search
+18
-1
@@ -148,6 +148,7 @@ class Issue < ActiveRecord::Base
|
|||||||
|
|
||||||
def reload(*args)
|
def reload(*args)
|
||||||
@workflow_rule_by_attribute = nil
|
@workflow_rule_by_attribute = nil
|
||||||
|
@assignable_versions = nil
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -252,6 +253,8 @@ class Issue < ActiveRecord::Base
|
|||||||
write_attribute(:project_id, project ? project.id : nil)
|
write_attribute(:project_id, project ? project.id : nil)
|
||||||
association_instance_set('project', project)
|
association_instance_set('project', project)
|
||||||
if project_was && project && project_was != project
|
if project_was && project && project_was != project
|
||||||
|
@assignable_versions = nil
|
||||||
|
|
||||||
unless keep_tracker || project.trackers.include?(tracker)
|
unless keep_tracker || project.trackers.include?(tracker)
|
||||||
self.tracker = project.trackers.first
|
self.tracker = project.trackers.first
|
||||||
end
|
end
|
||||||
@@ -639,7 +642,21 @@ class Issue < ActiveRecord::Base
|
|||||||
|
|
||||||
# Versions that the issue can be assigned to
|
# Versions that the issue can be assigned to
|
||||||
def assignable_versions
|
def assignable_versions
|
||||||
@assignable_versions ||= (project.shared_versions.open + [Version.find_by_id(fixed_version_id_was)]).compact.uniq.sort
|
return @assignable_versions if @assignable_versions
|
||||||
|
|
||||||
|
versions = project.shared_versions.open.all
|
||||||
|
if fixed_version
|
||||||
|
if fixed_version_id_changed?
|
||||||
|
# nothing to do
|
||||||
|
elsif project_id_changed?
|
||||||
|
if project.shared_versions.include?(fixed_version)
|
||||||
|
versions << fixed_version
|
||||||
|
end
|
||||||
|
else
|
||||||
|
versions << fixed_version
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@assignable_versions = versions.uniq.sort
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns true if this issue is blocked by another issue that is still open
|
# Returns true if this issue is blocked by another issue that is still open
|
||||||
|
|||||||
@@ -760,6 +760,26 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
assert issue.save
|
assert issue.save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_should_not_be_able_to_keep_unshared_version_when_changing_project
|
||||||
|
issue = Issue.find(2)
|
||||||
|
assert_equal 2, issue.fixed_version_id
|
||||||
|
issue.project_id = 3
|
||||||
|
assert_nil issue.fixed_version_id
|
||||||
|
issue.fixed_version_id = 2
|
||||||
|
assert !issue.save
|
||||||
|
assert_include 'Target version is not included in the list', issue.errors.full_messages
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_should_keep_shared_version_when_changing_project
|
||||||
|
Version.find(2).update_attribute :sharing, 'tree'
|
||||||
|
|
||||||
|
issue = Issue.find(2)
|
||||||
|
assert_equal 2, issue.fixed_version_id
|
||||||
|
issue.project_id = 3
|
||||||
|
assert_equal 2, issue.fixed_version_id
|
||||||
|
assert issue.save
|
||||||
|
end
|
||||||
|
|
||||||
def test_allowed_target_projects_on_move_should_include_projects_with_issue_tracking_enabled
|
def test_allowed_target_projects_on_move_should_include_projects_with_issue_tracking_enabled
|
||||||
assert_include Project.find(2), Issue.allowed_target_projects_on_move(User.find(2))
|
assert_include Project.find(2), Issue.allowed_target_projects_on_move(User.find(2))
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in new issue
Block a user