diff options
author | Robert Speicher <robert@gitlab.com> | 2017-03-17 16:40:04 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2017-03-17 16:40:04 +0000 |
commit | bb1620aaf712c22c61fda098260f481ad79a05e2 (patch) | |
tree | 3175d32663402d89d11c9bbc0485b7e667939404 | |
parent | 1a4aa8d72745a8ec6574c55a2fce000437608a0f (diff) | |
parent | 76f7cf924b2a5e2069a2332c526e16a9c9c45136 (diff) | |
download | gitlab-ce-bb1620aaf712c22c61fda098260f481ad79a05e2.tar.gz |
Merge branch 'fix-time-sensitive-helper-spec' into 'master'
Fix time-sensitive helper spec
See merge request !10046
-rw-r--r-- | spec/helpers/milestones_helper_spec.rb | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/spec/helpers/milestones_helper_spec.rb b/spec/helpers/milestones_helper_spec.rb index 87653631c28..3cb809d42b5 100644 --- a/spec/helpers/milestones_helper_spec.rb +++ b/spec/helpers/milestones_helper_spec.rb @@ -49,8 +49,12 @@ describe MilestonesHelper do end describe '#milestone_remaining_days' do + around do |example| + Timecop.freeze(Time.utc(2017, 3, 17)) { example.run } + end + context 'when less than 31 days remaining' do - let(:milestone_remaining) { milestone_remaining_days(build_stubbed(:milestone, due_date: 12.2.days.from_now)) } + let(:milestone_remaining) { milestone_remaining_days(build_stubbed(:milestone, due_date: 12.days.from_now.utc)) } it 'returns days remaining' do expect(milestone_remaining).to eq("<strong>12</strong> days remaining") @@ -58,7 +62,7 @@ describe MilestonesHelper do end context 'when less than 1 year and more than 30 days remaining' do - let(:milestone_remaining) { milestone_remaining_days(build_stubbed(:milestone, due_date: 2.months.from_now)) } + let(:milestone_remaining) { milestone_remaining_days(build_stubbed(:milestone, due_date: 2.months.from_now.utc)) } it 'returns months remaining' do expect(milestone_remaining).to eq("<strong>2</strong> months remaining") @@ -66,7 +70,7 @@ describe MilestonesHelper do end context 'when more than 1 year remaining' do - let(:milestone_remaining) { milestone_remaining_days(build_stubbed(:milestone, due_date: 1.year.from_now + 2.days)) } + let(:milestone_remaining) { milestone_remaining_days(build_stubbed(:milestone, due_date: (1.year.from_now + 2.days).utc)) } it 'returns years remaining' do expect(milestone_remaining).to eq("<strong>1</strong> year remaining") @@ -74,7 +78,7 @@ describe MilestonesHelper do end context 'when milestone is expired' do - let(:milestone_remaining) { milestone_remaining_days(build_stubbed(:milestone, due_date: 2.days.ago)) } + let(:milestone_remaining) { milestone_remaining_days(build_stubbed(:milestone, due_date: 2.days.ago.utc)) } it 'returns "Past due"' do expect(milestone_remaining).to eq("<strong>Past due</strong>") @@ -82,7 +86,7 @@ describe MilestonesHelper do end context 'when milestone has start_date in the future' do - let(:milestone_remaining) { milestone_remaining_days(build_stubbed(:milestone, start_date: 2.days.from_now)) } + let(:milestone_remaining) { milestone_remaining_days(build_stubbed(:milestone, start_date: 2.days.from_now.utc)) } it 'returns "Upcoming"' do expect(milestone_remaining).to eq("<strong>Upcoming</strong>") @@ -90,7 +94,7 @@ describe MilestonesHelper do end context 'when milestone has start_date in the past' do - let(:milestone_remaining) { milestone_remaining_days(build_stubbed(:milestone, start_date: 2.days.ago)) } + let(:milestone_remaining) { milestone_remaining_days(build_stubbed(:milestone, start_date: 2.days.ago.utc)) } it 'returns days elapsed' do expect(milestone_remaining).to eq("<strong>2</strong> days elapsed") |