diff options
author | Rémy Coutable <remy@rymai.me> | 2017-03-17 15:32:03 +0100 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-03-17 16:14:04 +0100 |
commit | 76f7cf924b2a5e2069a2332c526e16a9c9c45136 (patch) | |
tree | dd896af534ab1eba2e896afb0a21da1e591155ed /spec/helpers | |
parent | 1ac6bb553f7d0afc3583ad41a97a4cade918b6c7 (diff) | |
download | gitlab-ce-76f7cf924b2a5e2069a2332c526e16a9c9c45136.tar.gz |
Fix time-sensitive helper spec
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'spec/helpers')
-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") |