diff options
author | Alfredo Sumaran <alfredo@gitlab.com> | 2016-08-24 12:29:27 -0500 |
---|---|---|
committer | Alfredo Sumaran <alfredo@gitlab.com> | 2016-09-07 15:27:14 -0500 |
commit | 8499de19c9bca4c43378b8a9cf2b6705f9cab647 (patch) | |
tree | e22d78a3b9ed7077e8c24f0bd72c4c08673af9ce /spec/helpers/milestones_helper_spec.rb | |
parent | 19e2bf1c21a853e45db0c18133e5f1b1234ad09f (diff) | |
download | gitlab-ce-8499de19c9bca4c43378b8a9cf2b6705f9cab647.tar.gz |
Ensure milestone counts work with no datagitlab-ce-milestone-tab-badges
Commit originally written by @smcgivern
Diffstat (limited to 'spec/helpers/milestones_helper_spec.rb')
-rw-r--r-- | spec/helpers/milestones_helper_spec.rb | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/spec/helpers/milestones_helper_spec.rb b/spec/helpers/milestones_helper_spec.rb index d65610723b0..28c2268f8d0 100644 --- a/spec/helpers/milestones_helper_spec.rb +++ b/spec/helpers/milestones_helper_spec.rb @@ -3,33 +3,31 @@ require 'spec_helper' describe MilestonesHelper do describe '#milestone_counts' do let(:project) { FactoryGirl.create(:project) } - 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) } - let(:counts) { helper.milestone_counts(project.milestones) } - it 'returns a hash containing three items' do - expect(counts.length).to eq 3 - end + 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) } - it 'returns a hash containing "opened" key' do - expect(counts.has_key?(:opened)).to eq true + it 'returns the correct counts' do + expect(counts).to eq(opened: 2, closed: 1, all: 3) + end end - it 'returns a hash containing "closed" key' do - expect(counts.has_key?(:closed)).to eq true - end + 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) } - it 'returns a hash containing "all" key' do - expect(counts.has_key?(:all)).to eq true + it 'returns the correct counts' do + expect(counts).to eq(opened: 2, closed: 0, all: 2) + end end - it 'shows "all" object is the sum of "opened" and "closed" objects' do - puts counts.as_json - total = counts[:opened] + counts[:closed] - expect(counts[:all]).to eq total + context 'when there are no milestones' do + it 'returns the correct counts' do + expect(counts).to eq(opened: 0, closed: 0, all: 0) + end end end end -
\ No newline at end of file |