]> source.dussan.org Git - redmine.git/commitdiff
closed_on field of copied issue is always set to source issue's value (#23764).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 1 Oct 2016 07:43:22 +0000 (07:43 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 1 Oct 2016 07:43:22 +0000 (07:43 +0000)
Patch by Go MAEDA.

git-svn-id: http://svn.redmine.org/redmine/trunk@15848 e93f8b46-1217-0410-a6f0-8f06a7374b81

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

index 4e32dcec1c8abc566fa8b51aab5a8a66268b8195..d550616a9137879542de64b3b43f0584f87a1c91 100644 (file)
@@ -262,7 +262,7 @@ class Issue < ActiveRecord::Base
   # Copies attributes from another issue, arg can be an id or an Issue
   def copy_from(arg, options={})
     issue = arg.is_a?(Issue) ? arg : Issue.visible.find(arg)
-    self.attributes = issue.attributes.dup.except("id", "root_id", "parent_id", "lft", "rgt", "created_on", "updated_on")
+    self.attributes = issue.attributes.dup.except("id", "root_id", "parent_id", "lft", "rgt", "created_on", "updated_on", "closed_on")
     self.custom_field_values = issue.custom_field_values.inject({}) {|h,v| h[v.custom_field_id] = v.value; h}
     self.status = issue.status
     self.author = User.current
@@ -1402,7 +1402,7 @@ class Issue < ActiveRecord::Base
     end
     Project.where(condition).having_trackers
   end
+
   # Returns a scope of trackers that user can assign the issue to
   def allowed_target_trackers(user=User.current)
     self.class.allowed_target_trackers(project, user, tracker_id_was)
index fa6063cfdae9c2e86d2dfb40be17b84a0f7b6bcc..d119b5fe6006ee1aab6b088b1d4a963395e3226e 100644 (file)
@@ -762,7 +762,7 @@ class IssueTest < ActiveSupport::TestCase
     user = User.find(2)
     group = Group.generate!
     group.users << user
+
     issue = Issue.generate!(:author_id => 1, :assigned_to => group)
     assert_include 4, issue.new_statuses_allowed_to(user).map(&:id)
   end
@@ -1335,6 +1335,16 @@ class IssueTest < ActiveSupport::TestCase
     end
   end
 
+  def test_copy_should_clear_closed_on
+    copied_open = Issue.find(8).copy(:status_id => 1)
+    assert copied_open.save
+    assert_nil copied_open.closed_on
+
+    copied_closed = Issue.find(8).copy
+    assert copied_closed.save
+    assert_not_nil copied_closed.closed_on
+  end
+
   def test_should_not_call_after_project_change_on_creation
     issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1,
                       :subject => 'Test', :author_id => 1)