summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2021-03-29 05:52:37 +0000
committerGo MAEDA <maeda@farend.jp>2021-03-29 05:52:37 +0000
commit9feea028e0d79c9a738331d15837086d60782231 (patch)
treece7342235319784d219ef6ea7f22d97636ff70f3
parentdf2fdeeba3618658feab4df26804984000d83929 (diff)
downloadredmine-9feea028e0d79c9a738331d15837086d60782231.tar.gz
redmine-9feea028e0d79c9a738331d15837086d60782231.zip
Merged r20872 from trunk to 4.1-stable (#34921).
git-svn-id: http://svn.redmine.org/redmine/branches/4.1-stable@20874 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/models/issue.rb2
-rw-r--r--test/unit/issue_test.rb17
2 files changed, 18 insertions, 1 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb
index 6a26cf5de..12277b9ba 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -1758,7 +1758,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
diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb
index 1c49d0462..9a7124377 100644
--- a/test/unit/issue_test.rb
+++ b/test/unit/issue_test.rb
@@ -1476,6 +1476,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)