diff options
author | tony <tony> | 2009-03-10 08:16:43 +0000 |
---|---|---|
committer | tony <tony> | 2009-03-10 08:16:43 +0000 |
commit | a0a6a42b7bcfdac236feea9e1f05f66f88a3677c (patch) | |
tree | 84602f62abb3f6c4256b0f57d052eff5ae385e16 /spec/models/holiday_spec.rb | |
parent | 301d967cd55264b36481d5e30ac7e58e7d0b5d73 (diff) |
Move due date counting code into Holiday class
Diffstat (limited to 'spec/models/holiday_spec.rb')
-rw-r--r-- | spec/models/holiday_spec.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/spec/models/holiday_spec.rb b/spec/models/holiday_spec.rb new file mode 100644 index 000000000..f4dfc7476 --- /dev/null +++ b/spec/models/holiday_spec.rb @@ -0,0 +1,43 @@ +require File.dirname(__FILE__) + '/../spec_helper' + +describe Holiday, " when calculating due date" do + fixtures :holidays + + def due_date(ymd) + return Holiday.due_date_from(Date.strptime(ymd)).strftime("%F") + end + + it "handles no holidays" do + due_date('2008-10-01').should == '2008-10-29' + end + + it "handles non leap years" do + due_date('2007-02-01').should == '2007-03-01' + end + + it "handles leap years" do + due_date('2008-02-01').should == '2008-02-29' + end + + it "handles Thursday start" do + due_date('2009-03-12').should == '2009-04-14' + end + + it "handles Friday start" do + due_date('2009-03-13').should == '2009-04-15' + end + + it "handles Saturday start" do + due_date('2009-03-14').should == '2009-04-16' + end + + it "handles Sunday start" do + due_date('2009-03-15').should == '2009-04-16' + end + + it "handles Monday start" do + due_date('2009-03-16').should == '2009-04-16' + end + +end + |