Skip to content

Commit

Permalink
Do not add duplicate paths to Cocaine::CommandLine.path for each run.
Browse files Browse the repository at this point in the history
  • Loading branch information
boone committed Mar 5, 2012
1 parent 9092f7a commit 06d69af
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/paperclip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def interpolates key, &block
#
def run(cmd, arguments = "", local_options = {})
command_path = options[:command_path]
Cocaine::CommandLine.path = ( Cocaine::CommandLine.path ? [Cocaine::CommandLine.path, command_path ].flatten : command_path )
Cocaine::CommandLine.path = ( Cocaine::CommandLine.path ? [Cocaine::CommandLine.path].flatten | [command_path] : command_path )
local_options = local_options.merge(:logger => logger) if logging? && (options[:log_command] || local_options[:log_command])
Cocaine::CommandLine.new(cmd, arguments, local_options).run
end
Expand Down
9 changes: 9 additions & 0 deletions test/paperclip_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ class PaperclipTest < Test::Unit::TestCase
Paperclip.run("convert", "stuff")
assert_equal [Cocaine::CommandLine.path].flatten.include?("/opt/my_app/bin"), true
end

should "not duplicate Cocaine::CommandLine.path on multiple runs" do
Cocaine::CommandLine.expects(:new).with("convert", "more_stuff", {}).returns(stub(:run))
Cocaine::CommandLine.path = nil
Paperclip.options[:command_path] = "/opt/my_app/bin"
Paperclip.run("convert", "stuff")
Paperclip.run("convert", "more_stuff")
assert_equal 1, [Cocaine::CommandLine.path].flatten.size
end
end

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

0 comments on commit 06d69af

Please sign in to comment.