@@ -77,7 +77,9 class Issue < ActiveRecord::Base | |||
|
77 | 77 | self.relations_to.clear |
|
78 | 78 | end |
|
79 | 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 | 83 | self.fixed_version = nil |
|
82 | 84 | self.project = new_project |
|
83 | 85 | end |
@@ -14,4 +14,9 issue_categories_003: | |||
|
14 | 14 | project_id: 2 |
|
15 | 15 | assigned_to_id: |
|
16 | 16 | id: 3 |
|
17 | issue_categories_004: | |
|
18 | name: Printing | |
|
19 | project_id: 2 | |
|
20 | assigned_to_id: | |
|
21 | id: 4 | |
|
17 | 22 | No newline at end of file |
@@ -165,17 +165,26 class IssueTest < Test::Unit::TestCase | |||
|
165 | 165 | assert !issue1.reload.closed? |
|
166 | 166 | end |
|
167 | 167 | |
|
168 | def test_move_to_another_project | |
|
168 | def test_move_to_another_project_with_same_category | |
|
169 | 169 | issue = Issue.find(1) |
|
170 | 170 | assert issue.move_to(Project.find(2)) |
|
171 | 171 | issue.reload |
|
172 | 172 | assert_equal 2, issue.project_id |
|
173 |
# Category |
|
|
174 |
assert_ |
|
|
173 | # Category changes | |
|
174 | assert_equal 4, issue.category_id | |
|
175 | 175 | # Make sure time entries were move to the target project |
|
176 | 176 | assert_equal 2, issue.time_entries.first.project_id |
|
177 | 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 | 188 | def test_issue_destroy |
|
180 | 189 | Issue.find(1).destroy |
|
181 | 190 | assert_nil Issue.find_by_id(1) |
General Comments 0
You need to be logged in to leave comments.
Login now