From a6d62710cd346e8f62ed372c091a2f890c68ac5e Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 24 May 2014 16:39:18 +0000 Subject: [PATCH] Merged r13125 (#16700). git-svn-id: http://svn.redmine.org/redmine/branches/2.5-stable@13164 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb | 2 +- test/unit/attachment_test.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb index ae7e605e1..a816490cc 100644 --- a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb +++ b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb @@ -87,7 +87,7 @@ module Redmine a = Attachment.find_by_token(token) next unless a a.filename = attachment['filename'] unless attachment['filename'].blank? - a.content_type = attachment['content_type'] + a.content_type = attachment['content_type'] unless attachment['content_type'].blank? end next unless a a.description = attachment['description'].to_s.strip diff --git a/test/unit/attachment_test.rb b/test/unit/attachment_test.rb index 47992299e..6a077fcc2 100644 --- a/test/unit/attachment_test.rb +++ b/test/unit/attachment_test.rb @@ -241,6 +241,15 @@ class AttachmentTest < ActiveSupport::TestCase end end + test "Attachment.attach_files should preserve the content_type of attachments added by token" do + @project = Project.find(1) + attachment = Attachment.create!(:file => uploaded_test_file("testfile.txt", ""), :author_id => 1, :created_on => 2.days.ago) + assert_equal 'text/plain', attachment.content_type + Attachment.attach_files(@project, { '1' => {'token' => attachment.token } }) + attachment.reload + assert_equal 'text/plain', attachment.content_type + end + def test_latest_attach set_fixtures_attachments_directory a1 = Attachment.find(16) -- 2.39.5