diff options
author | Andrew8xx8 <avk@8xx8.ru> | 2013-02-18 13:38:29 +0400 |
---|---|---|
committer | Andrew8xx8 <avk@8xx8.ru> | 2013-02-18 14:43:50 +0400 |
commit | b607c70e8fc53adfd3472c98f573bf96d903b822 (patch) | |
tree | bad71a109ce90a980b593a46cf20813e0e2a84fa /spec | |
parent | 0b4f4fe157828430eb7b7a0d88c022d72fa01637 (diff) |
Additional tests added to Milestone
Diffstat (limited to 'spec')
-rw-r--r-- | spec/factories.rb | 6 | ||||
-rw-r--r-- | spec/models/milestone_spec.rb | 27 |
2 files changed, 33 insertions, 0 deletions
diff --git a/spec/factories.rb b/spec/factories.rb index 3f357b79496..74fcd111883 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -163,6 +163,12 @@ FactoryGirl.define do factory :milestone do title project + + trait :closed do + state :closed + end + + factory :closed_milestone, traits: [:closed] end factory :system_hook do diff --git a/spec/models/milestone_spec.rb b/spec/models/milestone_spec.rb index cdf0715a869..0f6317efc1a 100644 --- a/spec/models/milestone_spec.rb +++ b/spec/models/milestone_spec.rb @@ -108,4 +108,31 @@ describe Milestone do describe :can_be_closed? do it { milestone.can_be_closed?.should be_true } end + + describe :is_empty? do + it 'Should return total count of issues and merge requests assigned to milestone' do + issue = create :closed_issue, milestone: milestone + merge_request = create :merge_request, milestone: milestone + + milestone.total_items_count.should eq 2 + end + end + + describe :can_be_closed? do + it 'should be true if milestone active and all nestied issues closed' do + milestone = create :milestone + closed_issue = create :closed_issue, milestone: milestone + + milestone.can_be_closed?.should be_true + end + + it 'should be false if milestone active and not all nestied issues closed' do + milestone = create :milestone + closed_issue = create :closed_issue, milestone: milestone + issue = create :issue, milestone: milestone + + milestone.can_be_closed?.should be_false + end + end + end |