diff --git a/lib/resque_job_logging.rb b/lib/resque_job_logging.rb index ad4214b6a..91b980046 100644 --- a/lib/resque_job_logging.rb +++ b/lib/resque_job_logging.rb @@ -16,8 +16,7 @@ module ResqueJobLogging log_string += "status=complete " end log_string += "ms=#{time} " - arg_count = 1 - args.each{|arg| log_string += "arg#{arg_count}=\"#{arg.to_s[0..30]}\" "} + args.each_with_index{|arg,idx| log_string += "arg#{idx.succ}=\"#{arg.to_s[0..30]}\" "} Rails.logger.info(log_string) raise error if error diff --git a/spec/lib/resque_job_logging_spec.rb b/spec/lib/resque_job_logging_spec.rb new file mode 100644 index 000000000..1bdc9b045 --- /dev/null +++ b/spec/lib/resque_job_logging_spec.rb @@ -0,0 +1,26 @@ +# Copyright (c) 2010, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3 or later. See +# the COPYRIGHT file. + +require 'spec_helper' + +describe ResqueJobLogging do + before do + Rails.stub!(:logger).and_return(mock()) + Rails.logger.should_receive(:auto_flushing=).with(1) + + Object.const_set("ResqueJobLoggingDummy", Class.new(Object)) + ResqueJobLoggingDummy.extend(ResqueJobLogging) + end + + after do + Rails.unstub!(:logger) + end + + # http://bugs.joindiaspora.com/issues/741 + it "should enumerate arguments" do + Rails.logger.should_receive(:info).with(/arg1="foo" arg2="bar" arg3="baz"/) + ## pass a nil block, so we can test the .info() output + ResqueJobLoggingDummy.around_perform_log_job("foo", "bar", "baz") {} + end +end