From fa6dd7ff76d2ccf9e3efeaff80bc023332981bdf Mon Sep 17 00:00:00 2001 From: Christopher Creighton Date: Tue, 25 Sep 2012 19:03:49 -0700 Subject: [PATCH] Duplicate spec for sending a notification and invert to test for issue 260 --- spec/models/notice_observer_spec.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+), 0 deletions(-) diff --git a/spec/models/notice_observer_spec.rb b/spec/models/notice_observer_spec.rb index e653302..d214191 100644 --- a/spec/models/notice_observer_spec.rb +++ b/spec/models/notice_observer_spec.rb @@ -65,5 +65,27 @@ describe NoticeObserver do :backtrace => [{ :error => 'Le Broken' }], :notifier => { 'name' => 'Notifier', 'version' => '1', 'url' => 'http://toad.com' }) end end + describe "should not send a notification if a notification service is not configured" do + let(:app) { app = Fabricate(:app, :email_at_notices => [1], :notification_service => Fabricate(:notification_service))} + let(:err) { Fabricate(:err, :problem => Fabricate(:problem, :app => app, :notices_count => 100)) } + + before do + Errbit::Config.per_app_email_at_notices = true + end + + after do + Errbit::Config.per_app_email_at_notices = false + end + + it "should not create a campfire notification" do + err.problem.stub(:notices_count) { 1 } + #app.notification_service.stub!(:create_notification).and_return(true) + app.stub!(:notification_recipients => %w('ryan@system88.com')) + app.notification_service.should_not_receive(:create_notification) + + Notice.create!(:err => err, :message => 'FooError: Too Much Bar', :server_environment => {'environment-name' => 'production'}, + :backtrace => [{ :error => 'Le Broken' }], :notifier => { 'name' => 'Notifier', 'version' => '1', 'url' => 'http://toad.com' }) + end + end end -- libgit2 0.21.2