Commit 02f16c9f by Mike Burns

Merge branch 'master' of https://github.com/olap/paperclip

parents b5671757 ac628a17
...@@ -65,7 +65,12 @@ module Paperclip ...@@ -65,7 +65,12 @@ module Paperclip
end end
def best_content_type_option(types) def best_content_type_option(types)
types.reject {|type| type.content_type.match(/\/x-/) }.first.content_type best = types.reject {|type| type.content_type.match(/\/x-/) }
if best.size == 0
types.first.content_type
else
best.first.content_type
end
end end
def type_from_file_command def type_from_file_command
......
...@@ -60,6 +60,16 @@ class FileAdapterTest < Test::Unit::TestCase ...@@ -60,6 +60,16 @@ class FileAdapterTest < Test::Unit::TestCase
end end
end end
context "file with multiple possible x-types but no official type" do
setup do
MIME::Types.stubs(:type_for).returns([MIME::Type.new('image/x-mp4'), MIME::Type.new('image/x-video')])
end
should "return the first" do
assert_equal "image/x-mp4", @subject.content_type
end
end
context "file with content type derived from file command on *nix" do context "file with content type derived from file command on *nix" do
setup do setup do
MIME::Types.stubs(:type_for).returns([]) MIME::Types.stubs(:type_for).returns([])
......
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