]> source.dussan.org Git - redmine.git/commitdiff
Copy issue status on project copy (#3877).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 16 Nov 2009 20:06:37 +0000 (20:06 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 16 Nov 2009 20:06:37 +0000 (20:06 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3075 e93f8b46-1217-0410-a6f0-8f06a7374b81

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

index ea6eb13072ef9ed8eafd1291210522cda415b6c7..cfc2a1bc0aada884a6f130ca790025f9c44e3e40 100644 (file)
@@ -80,6 +80,7 @@ class Issue < ActiveRecord::Base
     issue = arg.is_a?(Issue) ? arg : Issue.find(arg)
     self.attributes = issue.attributes.dup.except("id", "created_on", "updated_on")
     self.custom_values = issue.custom_values.collect {|v| v.clone}
+    self.status = issue.status
     self
   end
   
index 84ccef601642ea4c76dd5df180af43469b8eb513..3b0dd2697ce7d0091c3a426faa210060306ef181 100644 (file)
@@ -178,6 +178,16 @@ class IssueTest < ActiveSupport::TestCase
     assert_equal orig.tracker, issue.tracker
     assert_equal orig.custom_values.first.value, issue.custom_values.first.value
   end
+
+  def test_copy_should_copy_status
+    orig = Issue.find(8)
+    assert orig.status != IssueStatus.default
+    
+    issue = Issue.new.copy_from(orig)
+    assert issue.save
+    issue.reload
+    assert_equal orig.status, issue.status
+  end
   
   def test_should_close_duplicates
     # Create 3 issues
index b4bb4cc11bb94e87cfaf16494c2cfc84eb209eff..93e4bbf22aa077ea1fe02ac0fb8789ebd99c5a64 100644 (file)
@@ -406,6 +406,11 @@ class ProjectTest < ActiveSupport::TestCase
     end
 
     should "copy issues" do
+      @source_project.issues << Issue.generate!(:status_id => 5,
+                                                :subject => "copy issue status",
+                                                :tracker_id => 1,
+                                                :assigned_to_id => 2,
+                                                :project_id => @source_project.id)
       assert @project.valid?
       assert @project.issues.empty?
       assert @project.copy(@source_project)
@@ -416,6 +421,11 @@ class ProjectTest < ActiveSupport::TestCase
         assert ! issue.assigned_to.blank?
         assert_equal @project, issue.project
       end
+      
+      copied_issue = @project.issues.first(:conditions => {:subject => "copy issue status"})
+      assert copied_issue
+      assert copied_issue.status
+      assert_equal "Closed", copied_issue.status.name
     end
 
     should "change the new issues to use the copied version" do