diff options
author | Robert Speicher <rspeicher@gmail.com> | 2012-08-25 21:54:38 +0400 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2012-08-25 22:19:16 +0400 |
commit | 580ce4f2d85f89e81825c3b5993fd3ee68f4d93a (patch) | |
tree | 3dd334a9c5d401eceb88092fa18cc4fb272cf1ac /spec/models | |
parent | 232389f4e8ebaffd125985ce63439cea407e85d5 (diff) |
Minor cleanup to Milestone model and spec
Back-ported from my still-in-progress major cleanup.
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/milestone_spec.rb | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/spec/models/milestone_spec.rb b/spec/models/milestone_spec.rb index 880d3f307a3..e9acc4e2815 100644 --- a/spec/models/milestone_spec.rb +++ b/spec/models/milestone_spec.rb @@ -31,24 +31,33 @@ describe Milestone do it { milestone.should be_valid } - describe "Issues" do - before do + describe "#percent_complete" do + it "should not count open issues" do milestone.issues << issue + milestone.percent_complete.should == 0 end - it { milestone.percent_complete.should == 0 } + it "should count closed issues" do + issue.update_attributes(closed: true) + milestone.issues << issue + milestone.percent_complete.should == 100 + end - it do - issue.update_attributes closed: true + it "should recover from dividing by zero" do + milestone.issues.should_receive(:count).and_return(0) milestone.percent_complete.should == 100 end end - describe :expires_at do - before do - milestone.update_attributes due_date: Date.today + 1.day + describe "#expires_at" do + it "should be nil when due_date is unset" do + milestone.update_attributes(due_date: nil) + milestone.expires_at.should be_nil end - it { milestone.expires_at.should_not be_nil } + it "should not be nil when due_date is set" do + milestone.update_attributes(due_date: Date.tomorrow) + milestone.expires_at.should be_present + end end end |