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
02f16c9f
Commit
02f16c9f
authored
May 31, 2012
by
Mike Burns
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/olap/paperclip
parents
b5671757
ac628a17
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
1 deletions
+16
-1
lib/paperclip/io_adapters/file_adapter.rb
+6
-1
test/io_adapters/file_adapter_test.rb
+10
-0
No files found.
lib/paperclip/io_adapters/file_adapter.rb
View file @
02f16c9f
...
@@ -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
...
...
test/io_adapters/file_adapter_test.rb
View file @
02f16c9f
...
@@ -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
([])
...
...
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