added enumeration to args and a spec to verify it

This commit is contained in:
Philip Champon 2011-01-27 12:46:02 -05:00
parent 087e0389bb
commit 0588dafe6b
2 changed files with 27 additions and 2 deletions

View file

@ -16,8 +16,7 @@ module ResqueJobLogging
log_string += "status=complete " log_string += "status=complete "
end end
log_string += "ms=#{time} " log_string += "ms=#{time} "
arg_count = 1 args.each_with_index{|arg,idx| log_string += "arg#{idx.succ}=\"#{arg.to_s[0..30]}\" "}
args.each{|arg| log_string += "arg#{arg_count}=\"#{arg.to_s[0..30]}\" "}
Rails.logger.info(log_string) Rails.logger.info(log_string)
raise error if error raise error if error

View file

@ -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