Commit 2d76a27fbaf8263f9568fa8fef63b4e32217c108
1 parent
33ca83c6
Exists in
master
and in
1 other branch
When a new notice comes in for a resolved err mark it as unresolved
Showing
3 changed files
with
18 additions
and
2 deletions
Show diff stats
app/models/err.rb
@@ -23,7 +23,7 @@ class Err | @@ -23,7 +23,7 @@ class Err | ||
23 | 23 | ||
24 | def self.for(attrs) | 24 | def self.for(attrs) |
25 | app = attrs.delete(:app) | 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 | end | 27 | end |
28 | 28 | ||
29 | def resolve! | 29 | def resolve! |
app/models/notice.rb
@@ -34,6 +34,7 @@ class Notice | @@ -34,6 +34,7 @@ class Notice | ||
34 | :environment => hoptoad_notice['server-environment']['environment-name'], | 34 | :environment => hoptoad_notice['server-environment']['environment-name'], |
35 | :fingerprint => hoptoad_notice['fingerprint'] | 35 | :fingerprint => hoptoad_notice['fingerprint'] |
36 | }) | 36 | }) |
37 | + err.update_attributes(:resolved => false) if err.resolved? | ||
37 | 38 | ||
38 | err.notices.create!({ | 39 | err.notices.create!({ |
39 | :message => hoptoad_notice['error']['message'], | 40 | :message => hoptoad_notice['error']['message'], |
spec/models/notice_spec.rb
@@ -42,11 +42,26 @@ describe Notice do | @@ -42,11 +42,26 @@ describe Notice do | ||
42 | :action => 'verify', | 42 | :action => 'verify', |
43 | :environment => 'development', | 43 | :environment => 'development', |
44 | :fingerprint => 'fingerprintdigest' | 44 | :fingerprint => 'fingerprintdigest' |
45 | - }).and_return(err = Err.new) | 45 | + }).and_return(err = Factory(:err)) |
46 | err.notices.stub(:create!) | 46 | err.notices.stub(:create!) |
47 | @notice = Notice.from_xml(@xml) | 47 | @notice = Notice.from_xml(@xml) |
48 | end | 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 | it 'should create a new notice' do | 65 | it 'should create a new notice' do |
51 | @notice = Notice.from_xml(@xml) | 66 | @notice = Notice.from_xml(@xml) |
52 | @notice.should be_persisted | 67 | @notice.should be_persisted |