Commit edaa779134d18f3993be830c163d0acb2aa50f99
Committed by
Robert Lail
1 parent
f6c22e88
Exists in
master
and in
1 other branch
Added resolved_at timestamp to Problem
Showing
4 changed files
with
14 additions
and
1 deletions
Show diff stats
Gemfile
Gemfile.lock
| ... | ... | @@ -260,6 +260,7 @@ GEM |
| 260 | 260 | rack (>= 1.0.0) |
| 261 | 261 | thor (0.15.4) |
| 262 | 262 | tilt (1.3.3) |
| 263 | + timecop (0.3.5) | |
| 263 | 264 | treetop (1.4.10) |
| 264 | 265 | polyglot |
| 265 | 266 | polyglot (>= 0.3.1) |
| ... | ... | @@ -323,6 +324,7 @@ DEPENDENCIES |
| 323 | 324 | ruby-fogbugz |
| 324 | 325 | therubyracer |
| 325 | 326 | thin |
| 327 | + timecop | |
| 326 | 328 | uglifier (>= 1.0.3) |
| 327 | 329 | unicorn |
| 328 | 330 | useragent (~> 0.3.1) | ... | ... |
app/models/problem.rb
| ... | ... | @@ -9,6 +9,7 @@ class Problem |
| 9 | 9 | field :last_notice_at, :type => DateTime |
| 10 | 10 | field :last_deploy_at, :type => Time |
| 11 | 11 | field :resolved, :type => Boolean, :default => false |
| 12 | + field :resolved_at, :type => Time | |
| 12 | 13 | field :issue_link, :type => String |
| 13 | 14 | field :issue_type, :type => String |
| 14 | 15 | |
| ... | ... | @@ -52,7 +53,7 @@ class Problem |
| 52 | 53 | end |
| 53 | 54 | |
| 54 | 55 | def resolve! |
| 55 | - self.update_attributes!(:resolved => true, :notices_count => 0) | |
| 56 | + self.update_attributes!(:resolved => true, :resolved_at => Time.now, :notices_count => 0) | |
| 56 | 57 | end |
| 57 | 58 | |
| 58 | 59 | def unresolve! | ... | ... |
spec/models/problem_spec.rb
| ... | ... | @@ -87,6 +87,15 @@ describe Problem do |
| 87 | 87 | problem.should be_resolved |
| 88 | 88 | end |
| 89 | 89 | |
| 90 | + it "should record the time when it was resolved" do | |
| 91 | + problem = Fabricate(:problem) | |
| 92 | + expected_resolved_at = Time.now | |
| 93 | + Timecop.freeze(expected_resolved_at) do | |
| 94 | + problem.resolve! | |
| 95 | + end | |
| 96 | + problem.resolved_at.to_s.should == expected_resolved_at.to_s | |
| 97 | + end | |
| 98 | + | |
| 90 | 99 | it "should throw an err if it's not successful" do |
| 91 | 100 | problem = Fabricate(:problem) |
| 92 | 101 | problem.should_not be_resolved | ... | ... |