fix_content_type.patch

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

Download (1.58 KB)

View differences:

lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb
87 87
                a = Attachment.find_by_token(token)
88 88
                next unless a
89 89
                a.filename = attachment['filename'] unless attachment['filename'].blank?
90
                a.content_type = attachment['content_type']
90
                a.content_type = attachment['content_type'] unless attachment['content_type'].blank?
91 91
              end
92 92
              next unless a
93 93
              a.description = attachment['description'].to_s.strip
test/unit/attachment_test.rb
241 241
    end
242 242
  end
243 243

  
244
  test "Attachment.attach_files should preserve the content_type of attachments added by token" do
245
    @project = Project.find(1)
246
    attachment = Attachment.create!(:file => uploaded_test_file("testfile.txt", ""), :author_id => 1, :created_on => 2.days.ago)
247
    assert_equal 'text/plain', attachment.content_type
248
    Attachment.attach_files(@project, { '1' => {'token' => attachment.token } })
249
    attachment.reload
250
    assert_equal 'text/plain', attachment.content_type
251
  end
252

  
244 253
  def test_latest_attach
245 254
    set_fixtures_attachments_directory
246 255
    a1 = Attachment.find(16)