Permalink
Browse files

Don't try to send exception notifications if no recipients were defined.

  • Loading branch information...
1 parent c440902 commit 142c0784d4d995e9992f4c74845abfe687a70c27 Dimitrij Denissenko committed Nov 17, 2009
Showing with 8 additions and 1 deletion.
  1. +1 −1 app/controllers/application_controller.rb
  2. +7 −0 spec/controllers/application_controller_spec.rb
View
2 app/controllers/application_controller.rb
@@ -65,7 +65,7 @@ def rescue_action_in_public(exception) #:doc:
status_code = response_code_for_rescue(exception)
case status_code
when :internal_server_error
- ExceptionNotifier.deliver_exception_notification(exception, self, request, {})
+ ExceptionNotifier.deliver_exception_notification(exception, self, request, {}) if ExceptionNotifier.exception_recipients.any?
end
render_optional_error_file(status_code)
end
View
7 spec/controllers/application_controller_spec.rb
@@ -33,6 +33,7 @@ def do_rescue
before do
controller.stub!(:render)
ExceptionNotifier.stub!(:deliver_exception_notification)
+ ExceptionNotifier.stub!(:exception_recipients).and_return(['[DUMMY]'])
end
@@ -106,6 +107,12 @@ def do_rescue
ExceptionNotifier.should_receive(:deliver_exception_notification)
do_rescue
end
+
+ it 'should NOT send a notification email if no recipients were defined' do
+ ExceptionNotifier.should_receive(:exception_recipients).and_return([])
+ ExceptionNotifier.should_not_receive(:deliver_exception_notification)
+ do_rescue
+ end
end

0 comments on commit 142c078

Please sign in to comment.