When moving an issue to another project, reassign it to the category with same name if any (#1653).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1697 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
6ddea3396b
commit
b68fd4c04b
|
@ -77,7 +77,9 @@ class Issue < ActiveRecord::Base
|
||||||
self.relations_to.clear
|
self.relations_to.clear
|
||||||
end
|
end
|
||||||
# issue is moved to another project
|
# issue is moved to another project
|
||||||
self.category = nil
|
# reassign to the category with same name if any
|
||||||
|
new_category = category.nil? ? nil : new_project.issue_categories.find_by_name(category.name)
|
||||||
|
self.category = new_category
|
||||||
self.fixed_version = nil
|
self.fixed_version = nil
|
||||||
self.project = new_project
|
self.project = new_project
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,4 +14,9 @@ issue_categories_003:
|
||||||
project_id: 2
|
project_id: 2
|
||||||
assigned_to_id:
|
assigned_to_id:
|
||||||
id: 3
|
id: 3
|
||||||
|
issue_categories_004:
|
||||||
|
name: Printing
|
||||||
|
project_id: 2
|
||||||
|
assigned_to_id:
|
||||||
|
id: 4
|
||||||
|
|
|
@ -165,17 +165,26 @@ class IssueTest < Test::Unit::TestCase
|
||||||
assert !issue1.reload.closed?
|
assert !issue1.reload.closed?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_move_to_another_project
|
def test_move_to_another_project_with_same_category
|
||||||
issue = Issue.find(1)
|
issue = Issue.find(1)
|
||||||
assert issue.move_to(Project.find(2))
|
assert issue.move_to(Project.find(2))
|
||||||
issue.reload
|
issue.reload
|
||||||
assert_equal 2, issue.project_id
|
assert_equal 2, issue.project_id
|
||||||
# Category removed
|
# Category changes
|
||||||
assert_nil issue.category
|
assert_equal 4, issue.category_id
|
||||||
# Make sure time entries were move to the target project
|
# Make sure time entries were move to the target project
|
||||||
assert_equal 2, issue.time_entries.first.project_id
|
assert_equal 2, issue.time_entries.first.project_id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_move_to_another_project_without_same_category
|
||||||
|
issue = Issue.find(2)
|
||||||
|
assert issue.move_to(Project.find(2))
|
||||||
|
issue.reload
|
||||||
|
assert_equal 2, issue.project_id
|
||||||
|
# Category cleared
|
||||||
|
assert_nil issue.category_id
|
||||||
|
end
|
||||||
|
|
||||||
def test_issue_destroy
|
def test_issue_destroy
|
||||||
Issue.find(1).destroy
|
Issue.find(1).destroy
|
||||||
assert_nil Issue.find_by_id(1)
|
assert_nil Issue.find_by_id(1)
|
||||||
|
|
Loading…
Reference in New Issue