Commit 3052c8d70c933e76d8d2e1fc4cc08d541733027b

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

Track the last notice time for an error

Showing 2 changed files with 17 additions and 0 deletions   Show diff stats
app/models/error.rb
... ... @@ -16,4 +16,8 @@ class Error
16 16 self.where(attrs).first || create(attrs)
17 17 end
18 18  
  19 + def last_notice_at
  20 + notices.last.try(:created_at)
  21 + end
  22 +
19 23 end
20 24 \ No newline at end of file
... ...
spec/models/error_spec.rb
... ... @@ -40,4 +40,17 @@ describe Error do
40 40 end
41 41 end
42 42  
  43 + context '#last_notice_at' do
  44 + it "returns the created_at timestamp of the latest notice" do
  45 + error = Factory(:error)
  46 + error.last_notice_at.should be_nil
  47 +
  48 + notice1 = Factory(:notice, :error => error)
  49 + error.last_notice_at.should == notice1.created_at
  50 +
  51 + notice2 = Factory(:notice, :error => error)
  52 + error.last_notice_at.should == notice2.created_at
  53 + end
  54 + end
  55 +
43 56 end
44 57 \ No newline at end of file
... ...