Commit 8c7c1e8 Jon Yurek
committed Apr 26, 2010
1 parent 488ffd2 commit 8c7c1e8 Copy full SHA for 8c7c1e8
File tree 2 files changed +11
-8
lines changed
2 files changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,10 @@ def content_type
16
16
when "js" then "application/js"
17
17
when "csv" , "xml" , "css" then "text/#{ type } "
18
18
else
19
- Paperclip . run ( "file" , "--mime-type #{ self . path } " ) . split ( ':' ) . last . strip rescue "application/x-#{ type } "
19
+ # On BSDs, `file` doesn't give a result code of 1 if the file doesn't exist.
20
+ content_type = ( Paperclip . run ( "file" , "--mime-type #{ self . path } " ) . split ( ':' ) . last . strip rescue "application/x-#{ type } " )
21
+ content_type = "application/x-#{ type } " if content_type . match ( /\( .*?\) / )
22
+ content_type
20
23
end
21
24
end
22
25
Original file line number Diff line number Diff line change @@ -23,14 +23,14 @@ class << file
23
23
24
24
assert_equal content_type , file . content_type
25
25
end
26
+ end
27
+ end
26
28
27
- should "return a content_type of text/plain on a real file whose content_type is determined with the file command" do
28
- file = File . new ( File . join ( File . dirname ( __FILE__ ) , ".." , "LICENSE" ) )
29
- class << file
30
- include Paperclip ::Upfile
31
- end
32
- assert_equal 'text/plain' , file . content_type
33
- end
29
+ should "return a content_type of text/plain on a real file whose content_type is determined with the file command" do
30
+ file = File . new ( File . join ( File . dirname ( __FILE__ ) , ".." , "LICENSE" ) )
31
+ class << file
32
+ include Paperclip ::Upfile
34
33
end
34
+ assert_equal 'text/plain' , file . content_type
35
35
end
36
36
end
You can’t perform that action at this time.
0 commit comments