Commit 2d76a27fbaf8263f9568fa8fef63b4e32217c108

Authored by Jared Pace
1 parent 33ca83c6
Exists in master and in 1 other branch production

When a new notice comes in for a resolved err mark it as unresolved

app/models/err.rb
... ... @@ -23,7 +23,7 @@ class Err
23 23  
24 24 def self.for(attrs)
25 25 app = attrs.delete(:app)
26   - app.errs.unresolved.where(attrs).first || app.errs.create!(attrs)
  26 + app.errs.where(attrs).first || app.errs.create!(attrs)
27 27 end
28 28  
29 29 def resolve!
... ...
app/models/notice.rb
... ... @@ -34,6 +34,7 @@ class Notice
34 34 :environment => hoptoad_notice['server-environment']['environment-name'],
35 35 :fingerprint => hoptoad_notice['fingerprint']
36 36 })
  37 + err.update_attributes(:resolved => false) if err.resolved?
37 38  
38 39 err.notices.create!({
39 40 :message => hoptoad_notice['error']['message'],
... ...
spec/models/notice_spec.rb
... ... @@ -42,11 +42,26 @@ describe Notice do
42 42 :action => 'verify',
43 43 :environment => 'development',
44 44 :fingerprint => 'fingerprintdigest'
45   - }).and_return(err = Err.new)
  45 + }).and_return(err = Factory(:err))
46 46 err.notices.stub(:create!)
47 47 @notice = Notice.from_xml(@xml)
48 48 end
49 49  
  50 + it 'marks the err as unresolve if it was previously resolved' do
  51 + Err.should_receive(:for).with({
  52 + :app => @app,
  53 + :klass => 'HoptoadTestingException',
  54 + :component => 'application',
  55 + :action => 'verify',
  56 + :environment => 'development',
  57 + :fingerprint => 'fingerprintdigest'
  58 + }).and_return(err = Factory(:err, :resolved => true))
  59 + err.should be_resolved
  60 + @notice = Notice.from_xml(@xml)
  61 + @notice.err.should == err
  62 + @notice.err.should_not be_resolved
  63 + end
  64 +
50 65 it 'should create a new notice' do
51 66 @notice = Notice.from_xml(@xml)
52 67 @notice.should be_persisted
... ...