Commit 5d01c0886403c555eec0a0b8ae431dbc6037c9a9
1 parent
0aa4294c
Exists in
master
and in
1 other branch
extra testing of custom intervals for notifications
Showing
1 changed file
with
38 additions
and
1 deletions
Show diff stats
spec/models/notice_observer_spec.rb
| ... | ... | @@ -43,7 +43,7 @@ describe NoticeObserver do |
| 43 | 43 | end |
| 44 | 44 | end |
| 45 | 45 | |
| 46 | - describe "should send a notification if a notification service is configured" do | |
| 46 | + describe "should send a notification if a notification service is configured with defaults" do | |
| 47 | 47 | let(:app) { Fabricate(:app, :email_at_notices => [1], :notification_service => Fabricate(:campfire_notification_service))} |
| 48 | 48 | let(:err) { Fabricate(:err, :problem => Fabricate(:problem, :app => app, :notices_count => 100)) } |
| 49 | 49 | let(:backtrace) { Fabricate(:backtrace) } |
| ... | ... | @@ -103,4 +103,41 @@ describe NoticeObserver do |
| 103 | 103 | Fabricate(:notice, :err => err) |
| 104 | 104 | end |
| 105 | 105 | end |
| 106 | + | |
| 107 | + describe "should send a notification at desired intervals" do | |
| 108 | + let(:app) { Fabricate(:app, :email_at_notices => [1], :notification_service => Fabricate(:campfire_notification_service, :notify_at_notices => [1,2]))} | |
| 109 | + let(:backtrace) { Fabricate(:backtrace) } | |
| 110 | + | |
| 111 | + before do | |
| 112 | + Errbit::Config.per_app_email_at_notices = true | |
| 113 | + end | |
| 114 | + | |
| 115 | + after do | |
| 116 | + Errbit::Config.per_app_email_at_notices = false | |
| 117 | + end | |
| 118 | + | |
| 119 | + it "should create a campfire notification on first notice" do | |
| 120 | + err = Fabricate(:err, :problem => Fabricate(:problem, :app => app, :notices_count => 1)) | |
| 121 | + app.notification_service.should_receive(:create_notification) | |
| 122 | + | |
| 123 | + Notice.create!(:err => err, :message => 'FooError: Too Much Bar', :server_environment => {'environment-name' => 'production'}, | |
| 124 | + :backtrace => backtrace, :notifier => { 'name' => 'Notifier', 'version' => '1', 'url' => 'http://toad.com' }) | |
| 125 | + end | |
| 126 | + | |
| 127 | + it "should create a campfire notification on second notice" do | |
| 128 | + err = Fabricate(:err, :problem => Fabricate(:problem, :app => app, :notices_count => 1)) | |
| 129 | + app.notification_service.should_receive(:create_notification) | |
| 130 | + | |
| 131 | + Notice.create!(:err => err, :message => 'FooError: Too Much Bar', :server_environment => {'environment-name' => 'production'}, | |
| 132 | + :backtrace => backtrace, :notifier => { 'name' => 'Notifier', 'version' => '1', 'url' => 'http://toad.com' }) | |
| 133 | + end | |
| 134 | + | |
| 135 | + it "should not create a campfire notification on third notice" do | |
| 136 | + err = Fabricate(:err, :problem => Fabricate(:problem, :app => app, :notices_count => 1)) | |
| 137 | + app.notification_service.should_receive(:create_notification) | |
| 138 | + | |
| 139 | + Notice.create!(:err => err, :message => 'FooError: Too Much Bar', :server_environment => {'environment-name' => 'production'}, | |
| 140 | + :backtrace => backtrace, :notifier => { 'name' => 'Notifier', 'version' => '1', 'url' => 'http://toad.com' }) | |
| 141 | + end | |
| 142 | + end | |
| 106 | 143 | end | ... | ... |