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
This commit is contained in:
Jean-Philippe Lang 2014-05-02 07:38:04 +00:00
parent 382ca5055a
commit 61776a8b7e
2 changed files with 10 additions and 1 deletions

View File

@ -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

View File

@ -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)