]> source.dussan.org Git - redmine.git/commitdiff
Merged r20872 from trunk to 4.2-stable (#34921).
authorGo MAEDA <maeda@farend.jp>
Mon, 29 Mar 2021 05:50:16 +0000 (05:50 +0000)
committerGo MAEDA <maeda@farend.jp>
Mon, 29 Mar 2021 05:50:16 +0000 (05:50 +0000)
git-svn-id: http://svn.redmine.org/redmine/branches/4.2-stable@20873 e93f8b46-1217-0410-a6f0-8f06a7374b81

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

index 50a52f4faa426c2b2be02624796f71ec162bd07b..e5bb30e25344e1b2628529d25e53aef26cd5ffd2 100644 (file)
@@ -1887,7 +1887,7 @@ class Issue < ActiveRecord::Base
 
   # Callback on file attachment
   def attachment_added(attachment)
-    if current_journal && !attachment.new_record?
+    if current_journal && !attachment.new_record? && !copy?
       current_journal.journalize_attachment(attachment, :added)
     end
   end
index ae59024e948780f811a51e9561d645498740d72a..34e0162cf35acabf68fccfb3aeeff0e2e180ea88 100644 (file)
@@ -1511,6 +1511,23 @@ class IssueTest < ActiveSupport::TestCase
     assert_equal [3, nil], copy.children.map(&:assigned_to_id)
   end
 
+  def test_copy_should_not_add_attachments_to_journal
+    set_tmp_attachments_directory
+    issue = Issue.generate!
+    copy = Issue.new
+    copy.init_journal User.find(1)
+    copy.copy_from issue
+
+    copy.project = issue.project
+    copy.save_attachments(
+      { 'p0' => {'file' => mock_file_with_options(:original_filename => 'upload')} }
+    )
+    assert copy.save
+    assert j = copy.journals.last
+    assert_equal 1, j.details.size
+    assert_equal 'relation', j.details[0].property
+  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)