1
0
mirror of https://github.com/meineerde/redmine.git synced 2025-12-19 15:01:14 +00:00

Merged r3566 from trunk.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/0.9-stable@3650 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2010-04-11 14:37:59 +00:00
parent 7ce9ba9e28
commit eb4a7f9f2e
2 changed files with 14 additions and 4 deletions

View File

@ -92,7 +92,7 @@ class Issue < ActiveRecord::Base
def move_to(new_project, new_tracker = nil, options = {}) def move_to(new_project, new_tracker = nil, options = {})
options ||= {} options ||= {}
issue = options[:copy] ? self.clone : self issue = options[:copy] ? self.clone : self
transaction do ret = Issue.transaction do
if new_project && issue.project_id != new_project.id if new_project && issue.project_id != new_project.id
# delete issue relations # delete issue relations
unless Setting.cross_project_issue_relations? unless Setting.cross_project_issue_relations?
@ -129,12 +129,12 @@ class Issue < ActiveRecord::Base
# Manually update project_id on related time entries # Manually update project_id on related time entries
TimeEntry.update_all("project_id = #{new_project.id}", {:issue_id => id}) TimeEntry.update_all("project_id = #{new_project.id}", {:issue_id => id})
end end
true
else else
Issue.connection.rollback_db_transaction raise ActiveRecord::Rollback
return false
end end
end end
return issue ret ? issue : false
end end
def priority_id=(pid) def priority_id=(pid)

View File

@ -386,6 +386,16 @@ class IssueTest < ActiveSupport::TestCase
assert_equal 7, issue.fixed_version_id assert_equal 7, issue.fixed_version_id
end end
def test_move_to_another_project_with_disabled_tracker
issue = Issue.find(1)
target = Project.find(2)
target.tracker_ids = [3]
target.save
assert_equal false, issue.move_to(target)
issue.reload
assert_equal 1, issue.project_id
end
def test_copy_to_the_same_project def test_copy_to_the_same_project
issue = Issue.find(1) issue = Issue.find(1)
copy = nil copy = nil