Project

General

Profile

Patch #16700 » fix_content_type.patch

Jens Krämer, 2014-04-16 12:58

View differences:

lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb
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
test/unit/attachment_test.rb
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)
    (1-1/1)