Commit 06fd651a4f22f9ae7ce0f78be861e67c2c21f066

Authored by anark
1 parent a1eb6072
Exists in master and in 1 other branch production

Reset notice count when an issue is resolved and send emails when appropriate

app/models/problem.rb
... ... @@ -47,7 +47,7 @@ class Problem
47 47 end
48 48  
49 49 def resolve!
50   - self.update_attributes!(:resolved => true)
  50 + self.update_attributes!(:resolved => true, :notices_count => 0)
51 51 end
52 52  
53 53 def unresolve!
... ...
spec/models/notice_spec.rb
... ... @@ -106,6 +106,24 @@ describe Notice do
106 106 end
107 107 end
108 108  
  109 + describe "email notifications for a resolved issue" do
109 110  
  111 + before do
  112 + Errbit::Config.per_app_email_at_notices = true
  113 + @app = Factory(:app_with_watcher, :email_at_notices => [1])
  114 + @err = Factory(:err, :problem => Factory(:problem, :app => @app, :notices_count => 100))
  115 + end
  116 +
  117 + after do
  118 + Errbit::Config.per_app_email_at_notices = false
  119 + end
  120 +
  121 + it "should send email notification after 1 notice since an error has been resolved" do
  122 + @err.problem.resolve!
  123 + Mailer.should_receive(:err_notification).
  124 + and_return(mock('email', :deliver => true))
  125 + Factory(:notice, :err => @err)
  126 + end
  127 + end
110 128 end
111 129  
... ...