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
20e9559a
Commit
20e9559a
authored
Jun 07, 2010
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Also give a CommandNotFoundError if backtick raises Errno::ENOENT.
parent
3f1390a6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
8 deletions
+18
-8
lib/paperclip.rb
+11
-7
test/paperclip_test.rb
+7
-1
No files found.
lib/paperclip.rb
View file @
20e9559a
...
...
@@ -112,16 +112,20 @@ module Paperclip
command
=
"
#{
command
}
2>
#{
bit_bucket
}
"
if
Paperclip
.
options
[
:swallow_stderr
]
Paperclip
.
log
(
command
)
if
Paperclip
.
options
[
:log_command
]
output
=
`
#{
command
}
`
begin
output
=
`
#{
command
}
`
if
$?
.
exitstatus
==
127
raise
CommandNotFoundError
if
$?
.
exitstatus
==
127
unless
expected_outcodes
.
include?
(
$?
.
exitstatus
)
raise
PaperclipCommandLineError
,
"Error while running
#{
cmd
}
. Expected return code to be
#{
expected_outcodes
.
join
(
", "
)
}
but was
#{
$?
.
exitstatus
}
"
,
output
end
rescue
Errno
::
ENOENT
=>
e
raise
CommandNotFoundError
end
unless
expected_outcodes
.
include?
(
$?
.
exitstatus
)
raise
PaperclipCommandLineError
,
"Error while running
#{
cmd
}
. Expected return code to be
#{
expected_outcodes
.
join
(
", "
)
}
but was
#{
$?
.
exitstatus
}
"
,
output
end
output
end
...
...
test/paperclip_test.rb
View file @
20e9559a
...
...
@@ -63,7 +63,7 @@ class PaperclipTest < Test::Unit::TestCase
end
context
"Calling Paperclip.run when the command is not found"
do
should
"tell you the command isn't there"
do
should
"tell you the command isn't there
if the shell returns 127
"
do
begin
assert_raises
(
Paperclip
::
CommandNotFoundError
)
do
`ruby -e 'exit 127'`
# Stub $?.exitstatus to be 127, i.e. Command Not Found.
...
...
@@ -74,6 +74,12 @@ class PaperclipTest < Test::Unit::TestCase
`ruby -e 'exit 0'`
# Unstub $?.exitstatus
end
end
should
"tell you the command isn't there if an ENOENT is raised"
do
assert_raises
(
Paperclip
::
CommandNotFoundError
)
do
Paperclip
.
stubs
(
:"`"
).
raises
(
Errno
::
ENOENT
)
Paperclip
.
run
(
"command"
)
end
end
end
should
"prevent dangerous characters in the command via quoting"
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