Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
Paperclip#run now respects swallow_stderr setting. Fix for #741
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Apolzon committed Feb 15, 2012
1 parent f19393c commit 58671eb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/paperclip.rb
Expand Up @@ -99,6 +99,7 @@ def run(cmd, arguments = "", local_options = {})
command_path = options[:command_path] || options[:image_magick_path]
Cocaine::CommandLine.path = ( Cocaine::CommandLine.path ? [Cocaine::CommandLine.path, command_path ].flatten : command_path )
local_options = local_options.merge(:logger => logger) if logging? && (options[:log_command] || local_options[:log_command])
local_options = local_options.merge(:swallow_stderr => options[:swallow_stderr]) if !local_options[:swallow_stderr] && !options[:swallow_stderr].nil?

This comment has been minimized.

Copy link
@cmaion

cmaion Feb 23, 2012

This is incorrect when options[:swallow_stderr] is true and local_options[:swallow_stderr] is false: in this case, swallow_stderr is forced to be true when we would expect local_options[:swall_stderr] to take precedence.

I guess that it should read:

local_options = local_options.merge(:swallow_stderr => options[:swallow_stderr]) if local_options[:swallow_stderr].nil? && !options[:swallow_stderr].nil?

Cocaine::CommandLine.new(cmd, arguments, local_options).run
end

Expand Down
13 changes: 13 additions & 0 deletions test/paperclip_test.rb
Expand Up @@ -4,6 +4,7 @@ class PaperclipTest < Test::Unit::TestCase
context "Calling Paperclip.run" do
setup do
Paperclip.options[:log_command] = false
Paperclip.options[:swallow_stderr] = nil
Cocaine::CommandLine.expects(:new).with("convert", "stuff", {}).returns(stub(:run))
@original_command_line_path = Cocaine::CommandLine.path
end
Expand All @@ -22,6 +23,18 @@ class PaperclipTest < Test::Unit::TestCase
Paperclip.run("convert", "stuff")
assert_equal [Cocaine::CommandLine.path].flatten.include?("/opt/my_app/bin"), true
end

should "respect Paperclip.options[:swallow_stderr]" do
Paperclip.options[:swallow_stderr] = false
Cocaine::CommandLine.unstub(:new)
Cocaine::CommandLine.expects(:new).with("convert", "stuff", {:swallow_stderr => false}).returns(stub(:run))
Paperclip.run("convert", "stuff")

Paperclip.options[:swallow_stderr] = true
Cocaine::CommandLine.unstub(:new)
Cocaine::CommandLine.expects(:new).with("convert", "stuff", {:swallow_stderr => true}).returns(stub(:run))
Paperclip.run("convert", "stuff")
end
end

context "Calling Paperclip.run with a logger" do
Expand Down

0 comments on commit 58671eb

Please sign in to comment.