diff options
author | Valery Sizov <valery@gitlab.com> | 2016-11-15 19:48:30 +0200 |
---|---|---|
committer | Valery Sizov <valery@gitlab.com> | 2016-11-23 13:41:04 +0200 |
commit | 3789cfe056c1d8a5fb91267cc2b1dd0f9f5902a9 (patch) | |
tree | 45314bfcb16ba7095e209d3a1f3eb9be2016b2a6 /spec/helpers | |
parent | d7eeb6df51ffe2ad864ef49d0e465b88ab158520 (diff) | |
download | gitlab-ce-3789cfe056c1d8a5fb91267cc2b1dd0f9f5902a9.tar.gz |
Add a starting date to milestonesmilestone_start_date
Diffstat (limited to 'spec/helpers')
-rw-r--r-- | spec/helpers/milestones_helper_spec.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/helpers/milestones_helper_spec.rb b/spec/helpers/milestones_helper_spec.rb index 28c2268f8d0..ea744dbb629 100644 --- a/spec/helpers/milestones_helper_spec.rb +++ b/spec/helpers/milestones_helper_spec.rb @@ -1,6 +1,25 @@ require 'spec_helper' describe MilestonesHelper do + describe "#milestone_date_range" do + def result_for(*args) + milestone_date_range(build(:milestone, *args)) + end + + let(:yesterday) { Date.yesterday } + let(:tomorrow) { yesterday + 2 } + let(:format) { '%b %-d, %Y' } + let(:yesterday_formatted) { yesterday.strftime(format) } + let(:tomorrow_formatted) { tomorrow.strftime(format) } + + it { expect(result_for(due_date: nil, start_date: nil)).to be_nil } + it { expect(result_for(due_date: tomorrow)).to eq("expires on #{tomorrow_formatted}") } + it { expect(result_for(due_date: yesterday)).to eq("expired on #{yesterday_formatted}") } + it { expect(result_for(start_date: tomorrow)).to eq("starts on #{tomorrow_formatted}") } + it { expect(result_for(start_date: yesterday)).to eq("started on #{yesterday_formatted}") } + it { expect(result_for(start_date: yesterday, due_date: tomorrow)).to eq("#{yesterday_formatted} - #{tomorrow_formatted}") } + end + describe '#milestone_counts' do let(:project) { FactoryGirl.create(:project) } let(:counts) { helper.milestone_counts(project.milestones) } |