@@ -101,7 +101,7 class Issue < ActiveRecord::Base | |||
|
101 | 101 | def move_to(new_project, new_tracker = nil, options = {}) |
|
102 | 102 | options ||= {} |
|
103 | 103 | issue = options[:copy] ? self.clone : self |
|
104 | transaction do | |
|
104 | ret = Issue.transaction do | |
|
105 | 105 | if new_project && issue.project_id != new_project.id |
|
106 | 106 | # delete issue relations |
|
107 | 107 | unless Setting.cross_project_issue_relations? |
@@ -138,12 +138,12 class Issue < ActiveRecord::Base | |||
|
138 | 138 | # Manually update project_id on related time entries |
|
139 | 139 | TimeEntry.update_all("project_id = #{new_project.id}", {:issue_id => id}) |
|
140 | 140 | end |
|
141 | true | |
|
141 | 142 | else |
|
142 | Issue.connection.rollback_db_transaction | |
|
143 | return false | |
|
143 | raise ActiveRecord::Rollback | |
|
144 | 144 | end |
|
145 | 145 | end |
|
146 |
ret |
|
|
146 | ret ? issue : false | |
|
147 | 147 | end |
|
148 | 148 | |
|
149 | 149 | def priority_id=(pid) |
@@ -387,6 +387,16 class IssueTest < ActiveSupport::TestCase | |||
|
387 | 387 | assert_equal 7, issue.fixed_version_id |
|
388 | 388 | end |
|
389 | 389 | |
|
390 | def test_move_to_another_project_with_disabled_tracker | |
|
391 | issue = Issue.find(1) | |
|
392 | target = Project.find(2) | |
|
393 | target.tracker_ids = [3] | |
|
394 | target.save | |
|
395 | assert_equal false, issue.move_to(target) | |
|
396 | issue.reload | |
|
397 | assert_equal 1, issue.project_id | |
|
398 | end | |
|
399 | ||
|
390 | 400 | def test_copy_to_the_same_project |
|
391 | 401 | issue = Issue.find(1) |
|
392 | 402 | copy = nil |
General Comments 0
You need to be logged in to leave comments.
Login now