diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-05-02 07:38:04 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-05-02 07:38:04 +0000 |
commit | 61776a8b7e60e2a794080b8d2b72c707086adfd8 (patch) | |
tree | 0ebacc25135a05a35ea06ffb6f0e110bc538fcbe | |
parent | 382ca5055a3a28726b5b66cb79856fbeaaaf73e9 (diff) | |
download | redmine-61776a8b7e60e2a794080b8d2b72c707086adfd8.tar.gz redmine-61776a8b7e60e2a794080b8d2b72c707086adfd8.zip |
Blank content type for attachments attached via Ajax file upload (Patch by Jens Krämer).
git-svn-id: http://svn.redmine.org/redmine/trunk@13125 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb | 2 | ||||
-rw-r--r-- | test/unit/attachment_test.rb | 9 |
2 files changed, 10 insertions, 1 deletions
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) |