diff options
author | tony <tony> | 2009-03-17 10:31:51 +0000 |
---|---|---|
committer | tony <tony> | 2009-03-17 10:31:51 +0000 |
commit | cf7999629d497bd076918a5e78a0ad9b173ab3dc (patch) | |
tree | 1c6ec95be875c1dc09546b1d466fee899868f233 /spec/models/info_request_spec.rb | |
parent | bc0ef954e7f3539147e4c1074ff4c04623511d28 (diff) |
Better days_overdue tests by overriding Time.now
Diffstat (limited to 'spec/models/info_request_spec.rb')
-rw-r--r-- | spec/models/info_request_spec.rb | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/spec/models/info_request_spec.rb b/spec/models/info_request_spec.rb index c2e8f34e2..9f258fb7c 100644 --- a/spec/models/info_request_spec.rb +++ b/spec/models/info_request_spec.rb @@ -110,13 +110,11 @@ describe InfoRequest, "when calculating status" do it "is awaiting response when recently new" do ir = send_msg(Time.new - 5.days) ir.calculate_status.should == 'waiting_response' - ir.days_overdue.should <= 0 end it "is overdue when very old" do ir = send_msg(Time.new - 50.days) ir.calculate_status.should == 'waiting_response_overdue' - ir.days_overdue.should > 0 end it "has correct due date" do @@ -124,5 +122,25 @@ describe InfoRequest, "when calculating status" do ir.date_response_required_by.strftime("%F").should == '2009-04-16' end + it "isn't overdue on due day" do + ir = send_msg(Time.utc(2009, 03, 16, 12, 0, 0)) + Time.class_eval do + def self.now + Time.utc(2009, 04, 16, 14, 0, 0) + end + end + ir.days_overdue.should == 0 + end + + it "is overdue a day after due day" do + ir = send_msg(Time.utc(2009, 03, 16, 12, 0, 0)) + Time.class_eval do + def self.now + Time.utc(2009, 04, 17, 11, 0, 0) + end + end + ir.days_overdue.should == 1 + end + end |