##// END OF EJS Templates
When moving an issue to another project, reassign it to the category with same name if any (#1653)....
Jean-Philippe Lang -
r1688:b68fd4c04bed
parent child
Show More
@@ -77,7 +77,9 class Issue < ActiveRecord::Base
77 self.relations_to.clear
77 self.relations_to.clear
78 end
78 end
79 # issue is moved to another project
79 # issue is moved to another project
80 self.category = nil
80 # reassign to the category with same name if any
81 new_category = category.nil? ? nil : new_project.issue_categories.find_by_name(category.name)
82 self.category = new_category
81 self.fixed_version = nil
83 self.fixed_version = nil
82 self.project = new_project
84 self.project = new_project
83 end
85 end
@@ -14,4 +14,9 issue_categories_003:
14 project_id: 2
14 project_id: 2
15 assigned_to_id:
15 assigned_to_id:
16 id: 3
16 id: 3
17 issue_categories_004:
18 name: Printing
19 project_id: 2
20 assigned_to_id:
21 id: 4
17 No newline at end of file
22
@@ -165,17 +165,26 class IssueTest < Test::Unit::TestCase
165 assert !issue1.reload.closed?
165 assert !issue1.reload.closed?
166 end
166 end
167
167
168 def test_move_to_another_project
168 def test_move_to_another_project_with_same_category
169 issue = Issue.find(1)
169 issue = Issue.find(1)
170 assert issue.move_to(Project.find(2))
170 assert issue.move_to(Project.find(2))
171 issue.reload
171 issue.reload
172 assert_equal 2, issue.project_id
172 assert_equal 2, issue.project_id
173 # Category removed
173 # Category changes
174 assert_nil issue.category
174 assert_equal 4, issue.category_id
175 # Make sure time entries were move to the target project
175 # Make sure time entries were move to the target project
176 assert_equal 2, issue.time_entries.first.project_id
176 assert_equal 2, issue.time_entries.first.project_id
177 end
177 end
178
178
179 def test_move_to_another_project_without_same_category
180 issue = Issue.find(2)
181 assert issue.move_to(Project.find(2))
182 issue.reload
183 assert_equal 2, issue.project_id
184 # Category cleared
185 assert_nil issue.category_id
186 end
187
179 def test_issue_destroy
188 def test_issue_destroy
180 Issue.find(1).destroy
189 Issue.find(1).destroy
181 assert_nil Issue.find_by_id(1)
190 assert_nil Issue.find_by_id(1)
General Comments 0
You need to be logged in to leave comments. Login now