Commit 3f1d30fb by Prem Sichanugrist

Call #content_type on MimeType object

This will ensure that the content type is a String.

Fixes #805
parent 4f6d482d
......@@ -63,7 +63,7 @@ module Paperclip
end
def best_content_type_option(types)
types.reject {|type| type.content_type.match(/\/x-/) }.first
types.reject {|type| type.content_type.match(/\/x-/) }.first.content_type
end
def type_from_file_command
......
......@@ -23,6 +23,10 @@ class FileAdapterTest < Test::Unit::TestCase
assert_equal "image/png", @subject.content_type
end
should "return content type as a string" do
assert_kind_of String, @subject.content_type
end
should "get the file's size" do
assert_equal 4456, @subject.size
end
......@@ -41,6 +45,20 @@ class FileAdapterTest < Test::Unit::TestCase
assert expected.length > 0
assert_equal expected, @subject.read
end
context "file with multiple possible content type" do
setup do
MIME::Types.stubs(:type_for).returns([MIME::Type.new('image/x-png'), MIME::Type.new('image/png')])
end
should "prefer officially registered mime type" do
assert_equal "image/png", @subject.content_type
end
should "return content type as a string" do
assert_kind_of String, @subject.content_type
end
end
end
context "empty file" do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment