Fix resque job logging spec

This commit is contained in:
Raphael Sofaer 2011-08-09 17:05:34 -07:00
parent cdfaa83e97
commit 333081f8b1
2 changed files with 7 additions and 6 deletions

View file

@ -24,20 +24,21 @@ module ResqueJobLogging
Rails.logger.info(log_string)
if error
notify_hoptoad(error, args) if AppConfig[:hoptoad_api_key].present? && Rails.env.production?
notify_hoptoad(error, args) if AppConfig[:hoptoad_api_key].present?
raise error
end
end
def notify_hoptoad error
def notify_hoptoad(error, job_arguments)
puts "Notifying hoptoad"
HoptoadNotifier.notify(
:error_class => error.class,
:error_message => error.message,
:parameters => {
:job_class => self.name,
:arguments => args
:arguments => job_arguments
}
)
) if Rails.env.production?
end
def application_trace(error) #copied from ActionDispatch::ShowExceptions

View file

@ -32,9 +32,9 @@ describe ResqueJobLogging do
it 'notifies hoptoad if the hoptoad api key is set' do
Rails.logger.should_receive(:info)
AppConfig.should_receive(:[]).with(:hoptoad_api_key).and_return "what"
AppConfig.should_receive(:[]).with(:hoptoad_api_key).and_return("what")
error = RuntimeError.new("GRAAAAAAAAAGH")
ResqueJobLoggingDummy.should_receive(:notify_hoptoad).with(error)
ResqueJobLoggingDummy.should_receive(:notify_hoptoad).with(error, ["stuff"])
proc {
ResqueJobLoggingDummy.around_perform_log_job("stuff"){raise error }
}.should raise_error