]> source.dussan.org Git - redmine.git/commitdiff
Merged r3566 from trunk.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 11 Apr 2010 14:37:59 +0000 (14:37 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 11 Apr 2010 14:37:59 +0000 (14:37 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/0.9-stable@3650 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/issue.rb
test/unit/issue_test.rb

index 725d7dafcf1ccd9eb525fd855cc1c64fcc425a66..6c491bf23825ab0761b3e7fb65e93cacd58d63d6 100644 (file)
@@ -92,7 +92,7 @@ class Issue < ActiveRecord::Base
   def move_to(new_project, new_tracker = nil, options = {})
     options ||= {}
     issue = options[:copy] ? self.clone : self
-    transaction do
+    ret = Issue.transaction do
       if new_project && issue.project_id != new_project.id
         # delete issue relations
         unless Setting.cross_project_issue_relations?
@@ -129,12 +129,12 @@ class Issue < ActiveRecord::Base
           # Manually update project_id on related time entries
           TimeEntry.update_all("project_id = #{new_project.id}", {:issue_id => id})
         end
+        true
       else
-        Issue.connection.rollback_db_transaction
-        return false
+        raise ActiveRecord::Rollback
       end
     end
-    return issue
+    ret ? issue : false
   end
   
   def priority_id=(pid)
index b22b05c78a5c2853ed2a91969b8c37878b85d82c..f2a67d160ff7f8101b80062cebb9a64e694e2659 100644 (file)
@@ -386,6 +386,16 @@ class IssueTest < ActiveSupport::TestCase
     assert_equal 7, issue.fixed_version_id
   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
     issue = Issue.find(1)
     copy = nil