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
b4369301
Commit
b4369301
authored
Jun 22, 2012
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make command line error handling more generic
parent
1d22cdca
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
10 deletions
+3
-10
lib/paperclip/content_type_detector.rb
+2
-1
test/content_type_detector_test.rb
+1
-9
No files found.
lib/paperclip/content_type_detector.rb
View file @
b4369301
...
...
@@ -52,7 +52,8 @@ module Paperclip
type
=
begin
# On BSDs, `file` doesn't give a result code of 1 if the file doesn't exist.
Paperclip
.
run
(
"file"
,
"-b --mime :file"
,
:file
=>
@filename
)
rescue
Cocaine
::
CommandNotFoundError
=>
e
rescue
Cocaine
::
CommandLineError
=>
e
Paperclip
.
log
(
"Error while determining content type:
#{
e
}
"
)
SENSIBLE_DEFAULT
end
...
...
test/content_type_detector_test.rb
View file @
b4369301
...
...
@@ -31,16 +31,8 @@ class ContentTypeDetectorTest < Test::Unit::TestCase
assert_equal
"application/octet-stream"
,
Paperclip
::
ContentTypeDetector
.
new
(
@filename
).
detect
end
should
'let errors raise if something blows up'
do
Paperclip
.
stubs
(
:run
).
raises
(
Cocaine
::
CommandLineError
.
new
)
@filename
=
"/path/to/something"
assert_raises
(
Cocaine
::
CommandLineError
)
do
Paperclip
::
ContentTypeDetector
.
new
(
@filename
).
detect
end
end
should
'return a sensible default when the file command is missing'
do
Paperclip
.
stubs
(
:run
).
raises
(
Cocaine
::
Command
NotFound
Error
.
new
)
Paperclip
.
stubs
(
:run
).
raises
(
Cocaine
::
Command
Line
Error
.
new
)
@filename
=
"/path/to/something"
assert_equal
"application/octet-stream"
,
Paperclip
::
ContentTypeDetector
.
new
(
@filename
).
detect
end
...
...
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