2016-07-25 17:23:27 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe MilestonesHelper do
|
|
|
|
describe '#milestone_counts' do
|
|
|
|
let(:project) { FactoryGirl.create(:project) }
|
|
|
|
let(:counts) { helper.milestone_counts(project.milestones) }
|
|
|
|
|
2016-08-24 13:29:27 -04:00
|
|
|
context 'when there are milestones' do
|
|
|
|
let!(:milestone_1) { FactoryGirl.create(:active_milestone, project: project) }
|
|
|
|
let!(:milestone_2) { FactoryGirl.create(:active_milestone, project: project) }
|
|
|
|
let!(:milestone_3) { FactoryGirl.create(:closed_milestone, project: project) }
|
2016-08-22 18:58:28 -04:00
|
|
|
|
2016-08-24 13:29:27 -04:00
|
|
|
it 'returns the correct counts' do
|
|
|
|
expect(counts).to eq(opened: 2, closed: 1, all: 3)
|
|
|
|
end
|
2016-07-25 17:23:27 -04:00
|
|
|
end
|
2016-08-22 18:58:28 -04:00
|
|
|
|
2016-08-24 13:29:27 -04:00
|
|
|
context 'when there are only milestones of one type' do
|
|
|
|
let!(:milestone_1) { FactoryGirl.create(:active_milestone, project: project) }
|
|
|
|
let!(:milestone_2) { FactoryGirl.create(:active_milestone, project: project) }
|
2016-08-22 18:58:28 -04:00
|
|
|
|
2016-08-24 13:29:27 -04:00
|
|
|
it 'returns the correct counts' do
|
|
|
|
expect(counts).to eq(opened: 2, closed: 0, all: 2)
|
|
|
|
end
|
2016-07-25 17:23:27 -04:00
|
|
|
end
|
|
|
|
|
2016-08-24 13:29:27 -04:00
|
|
|
context 'when there are no milestones' do
|
|
|
|
it 'returns the correct counts' do
|
|
|
|
expect(counts).to eq(opened: 0, closed: 0, all: 0)
|
|
|
|
end
|
2016-08-22 18:58:28 -04:00
|
|
|
end
|
2016-07-25 17:23:27 -04:00
|
|
|
end
|
|
|
|
end
|