From 87ffce4f641c68cc0643130036151e996d6f7bd8 Mon Sep 17 00:00:00 2001 From: Raphael Sofaer Date: Tue, 9 Aug 2011 16:04:23 -0700 Subject: [PATCH] Get hoptoad notifications working from resque --- lib/resque_job_logging.rb | 7 ++++--- spec/lib/resque_job_logging_spec.rb | 9 +++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/resque_job_logging.rb b/lib/resque_job_logging.rb index 4def287cc..ccf9f6a75 100644 --- a/lib/resque_job_logging.rb +++ b/lib/resque_job_logging.rb @@ -24,17 +24,18 @@ module ResqueJobLogging Rails.logger.info(log_string) if error - notify_hoptoad(error) 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 - Hoptoad.notify( + HoptoadNotifier.notify( :error_class => error.class, :error_message => error.message, :parameters => { - :job_class => self.name + :job_class => self.name, + :arguments => args} } ) end diff --git a/spec/lib/resque_job_logging_spec.rb b/spec/lib/resque_job_logging_spec.rb index ed7997d32..d4af125b4 100644 --- a/spec/lib/resque_job_logging_spec.rb +++ b/spec/lib/resque_job_logging_spec.rb @@ -28,6 +28,15 @@ describe ResqueJobLogging do proc { ResqueJobLoggingDummy.around_perform_log_job("stuff"){raise "GRAAAAAAAAAGH"} }.should raise_error + end + 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" + error = RuntimeError.new("GRAAAAAAAAAGH") + ResqueJobLoggingDummy.should_receive(:notify_hoptoad).with(error) + proc { + ResqueJobLoggingDummy.around_perform_log_job("stuff"){raise error } + }.should raise_error end end