##// END OF EJS Templates
Fixed: error while moving an issue to a project with disabled tracker with SQLite3 (#5049)....
Jean-Philippe Lang -
r3452:3dc4dbe30279
parent child
Show More
@@ -101,7 +101,7 class Issue < ActiveRecord::Base
101 def move_to(new_project, new_tracker = nil, options = {})
101 def move_to(new_project, new_tracker = nil, options = {})
102 options ||= {}
102 options ||= {}
103 issue = options[:copy] ? self.clone : self
103 issue = options[:copy] ? self.clone : self
104 transaction do
104 ret = Issue.transaction do
105 if new_project && issue.project_id != new_project.id
105 if new_project && issue.project_id != new_project.id
106 # delete issue relations
106 # delete issue relations
107 unless Setting.cross_project_issue_relations?
107 unless Setting.cross_project_issue_relations?
@@ -138,12 +138,12 class Issue < ActiveRecord::Base
138 # Manually update project_id on related time entries
138 # Manually update project_id on related time entries
139 TimeEntry.update_all("project_id = #{new_project.id}", {:issue_id => id})
139 TimeEntry.update_all("project_id = #{new_project.id}", {:issue_id => id})
140 end
140 end
141 true
141 else
142 else
142 Issue.connection.rollback_db_transaction
143 raise ActiveRecord::Rollback
143 return false
144 end
144 end
145 end
145 end
146 return issue
146 ret ? issue : false
147 end
147 end
148
148
149 def priority_id=(pid)
149 def priority_id=(pid)
@@ -387,6 +387,16 class IssueTest < ActiveSupport::TestCase
387 assert_equal 7, issue.fixed_version_id
387 assert_equal 7, issue.fixed_version_id
388 end
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 def test_copy_to_the_same_project
400 def test_copy_to_the_same_project
391 issue = Issue.find(1)
401 issue = Issue.find(1)
392 copy = nil
402 copy = nil
General Comments 0
You need to be logged in to leave comments. Login now