Skip to content
This repository
Browse code

Merge pull request #742 from apolzon/respect_swallow_stderr_option_wh…

…en_running_commands

Paperclip#run now respects swallow_stderr setting. Fix for #741
  • Loading branch information...
commit 6fca437d53610860d706a8add4db9048f912c18d 2 parents 56012bf + 58671eb
Prem Sichanugrist authored February 17, 2012
1  lib/paperclip.rb
@@ -99,6 +99,7 @@ def run(cmd, arguments = "", local_options = {})
99 99
       command_path = options[:command_path] || options[:image_magick_path]
100 100
       Cocaine::CommandLine.path = ( Cocaine::CommandLine.path ? [Cocaine::CommandLine.path, command_path ].flatten : command_path )
101 101
       local_options = local_options.merge(:logger => logger) if logging? && (options[:log_command] || local_options[:log_command])
  102
+      local_options = local_options.merge(:swallow_stderr => options[:swallow_stderr]) if !local_options[:swallow_stderr] && !options[:swallow_stderr].nil?
102 103
       Cocaine::CommandLine.new(cmd, arguments, local_options).run
103 104
     end
104 105
 
13  test/paperclip_test.rb
@@ -4,6 +4,7 @@ class PaperclipTest < Test::Unit::TestCase
4 4
   context "Calling Paperclip.run" do
5 5
     setup do
6 6
       Paperclip.options[:log_command] = false
  7
+      Paperclip.options[:swallow_stderr] = nil
7 8
       Cocaine::CommandLine.expects(:new).with("convert", "stuff", {}).returns(stub(:run))
8 9
       @original_command_line_path = Cocaine::CommandLine.path
9 10
     end
@@ -22,6 +23,18 @@ class PaperclipTest < Test::Unit::TestCase
22 23
       Paperclip.run("convert", "stuff")
23 24
       assert_equal [Cocaine::CommandLine.path].flatten.include?("/opt/my_app/bin"), true
24 25
     end
  26
+
  27
+    should "respect Paperclip.options[:swallow_stderr]" do
  28
+      Paperclip.options[:swallow_stderr] = false
  29
+      Cocaine::CommandLine.unstub(:new)
  30
+      Cocaine::CommandLine.expects(:new).with("convert", "stuff", {:swallow_stderr => false}).returns(stub(:run))
  31
+      Paperclip.run("convert", "stuff")
  32
+
  33
+      Paperclip.options[:swallow_stderr] = true
  34
+      Cocaine::CommandLine.unstub(:new)
  35
+      Cocaine::CommandLine.expects(:new).with("convert", "stuff", {:swallow_stderr => true}).returns(stub(:run))
  36
+      Paperclip.run("convert", "stuff")
  37
+    end
25 38
   end
26 39
 
27 40
   context "Calling Paperclip.run with a logger" do

0 notes on commit 6fca437

Please sign in to comment.
Something went wrong with that request. Please try again.