Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
paperclip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
paperclip
Commits
3f1d30fb
Commit
3f1d30fb
authored
Apr 17, 2012
by
Prem Sichanugrist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Call #content_type on MimeType object
This will ensure that the content type is a String. Fixes #805
parent
4f6d482d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
1 deletions
+19
-1
lib/paperclip/io_adapters/file_adapter.rb
+1
-1
test/file_adapter_test.rb
+18
-0
No files found.
lib/paperclip/io_adapters/file_adapter.rb
View file @
3f1d30fb
...
@@ -63,7 +63,7 @@ module Paperclip
...
@@ -63,7 +63,7 @@ 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
types
.
reject
{
|
type
|
type
.
content_type
.
match
(
/\/x-/
)
}.
first
.
content_type
end
end
def
type_from_file_command
def
type_from_file_command
...
...
test/file_adapter_test.rb
View file @
3f1d30fb
...
@@ -23,6 +23,10 @@ class FileAdapterTest < Test::Unit::TestCase
...
@@ -23,6 +23,10 @@ class FileAdapterTest < Test::Unit::TestCase
assert_equal
"image/png"
,
@subject
.
content_type
assert_equal
"image/png"
,
@subject
.
content_type
end
end
should
"return content type as a string"
do
assert_kind_of
String
,
@subject
.
content_type
end
should
"get the file's size"
do
should
"get the file's size"
do
assert_equal
4456
,
@subject
.
size
assert_equal
4456
,
@subject
.
size
end
end
...
@@ -41,6 +45,20 @@ class FileAdapterTest < Test::Unit::TestCase
...
@@ -41,6 +45,20 @@ class FileAdapterTest < Test::Unit::TestCase
assert
expected
.
length
>
0
assert
expected
.
length
>
0
assert_equal
expected
,
@subject
.
read
assert_equal
expected
,
@subject
.
read
end
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
end
context
"empty file"
do
context
"empty file"
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment