diff options
author | Heinrich Lee Yu <heinrich@gitlab.com> | 2019-08-24 04:05:39 +0800 |
---|---|---|
committer | Heinrich Lee Yu <heinrich@gitlab.com> | 2019-09-05 20:24:33 +0800 |
commit | 7a8d216480b8b33c38c56c28734deb96f74f0988 (patch) | |
tree | 202207921cfedf2f228c26795e3846878f1aa04f /spec/lib | |
parent | dd80d6229215d0ca4c3eae7bde1ac4b2a0d12d3c (diff) | |
download | gitlab-ce-7a8d216480b8b33c38c56c28734deb96f74f0988.tar.gz |
Fix time tracking parsing of months59729-estimate-quick-action-does-not-produce-correct-time-for-1mo
Patches ChronicDuration to use our custom conversions
when parsing months
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/patch/chronic_duration_spec.rb | 27 | ||||
-rw-r--r-- | spec/lib/gitlab/time_tracking_formatter_spec.rb | 8 |
2 files changed, 35 insertions, 0 deletions
diff --git a/spec/lib/gitlab/patch/chronic_duration_spec.rb b/spec/lib/gitlab/patch/chronic_duration_spec.rb new file mode 100644 index 00000000000..541037ec1a2 --- /dev/null +++ b/spec/lib/gitlab/patch/chronic_duration_spec.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Gitlab::Patch::ChronicDuration do + subject { ChronicDuration.parse('1mo') } + + it 'uses default conversions' do + expect(subject).to eq(2_592_000) + end + + context 'with custom conversions' do + before do + ChronicDuration.hours_per_day = 8 + ChronicDuration.days_per_week = 5 + end + + after do + ChronicDuration.hours_per_day = 24 + ChronicDuration.days_per_week = 7 + end + + it 'uses custom conversions' do + expect(subject).to eq(576_000) + end + end +end diff --git a/spec/lib/gitlab/time_tracking_formatter_spec.rb b/spec/lib/gitlab/time_tracking_formatter_spec.rb index a85d418777f..cfc804c13a7 100644 --- a/spec/lib/gitlab/time_tracking_formatter_spec.rb +++ b/spec/lib/gitlab/time_tracking_formatter_spec.rb @@ -17,6 +17,14 @@ describe Gitlab::TimeTrackingFormatter do it { expect(subject).to eq(-12_000) } end + + context 'durations with months' do + let(:duration_string) { '1mo' } + + it 'uses our custom conversions' do + expect(subject).to eq(576_000) + end + end end describe '#output' do |