Additional tests added to Milestone

This commit is contained in:
Andrew8xx8 2013-02-18 13:38:29 +04:00
parent 0b4f4fe157
commit b607c70e8f
2 changed files with 33 additions and 0 deletions

View file

@ -163,6 +163,12 @@ FactoryGirl.define do
factory :milestone do factory :milestone do
title title
project project
trait :closed do
state :closed
end
factory :closed_milestone, traits: [:closed]
end end
factory :system_hook do factory :system_hook do

View file

@ -108,4 +108,31 @@ describe Milestone do
describe :can_be_closed? do describe :can_be_closed? do
it { milestone.can_be_closed?.should be_true } it { milestone.can_be_closed?.should be_true }
end 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 end