diff options
author | Heinrich Lee Yu <heinrich@gitlab.com> | 2019-06-11 13:40:01 +0300 |
---|---|---|
committer | Heinrich Lee Yu <heinrich@gitlab.com> | 2019-06-25 04:31:23 +0300 |
commit | 275a17589c2d468d8671a9f754a50b212273d509 (patch) | |
tree | fb491229331aa09e74fd14385b0682e693774395 /spec/lib/gitlab/time_tracking_formatter_spec.rb | |
parent | 4e283ee706b11fd3b918230976addc9a70603ce6 (diff) |
Rename to time_tracking_limit_to_hours
Changes migration and all other places the attribute is used
Diffstat (limited to 'spec/lib/gitlab/time_tracking_formatter_spec.rb')
-rw-r--r-- | spec/lib/gitlab/time_tracking_formatter_spec.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/spec/lib/gitlab/time_tracking_formatter_spec.rb b/spec/lib/gitlab/time_tracking_formatter_spec.rb new file mode 100644 index 00000000000..a85d418777f --- /dev/null +++ b/spec/lib/gitlab/time_tracking_formatter_spec.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Gitlab::TimeTrackingFormatter do + describe '#parse' do + subject { described_class.parse(duration_string) } + + context 'positive durations' do + let(:duration_string) { '3h 20m' } + + it { expect(subject).to eq(12_000) } + end + + context 'negative durations' do + let(:duration_string) { '-3h 20m' } + + it { expect(subject).to eq(-12_000) } + end + end + + describe '#output' do + let(:num_seconds) { 178_800 } + + subject { described_class.output(num_seconds) } + + context 'time_tracking_limit_to_hours setting is true' do + before do + stub_application_setting(time_tracking_limit_to_hours: true) + end + + it { expect(subject).to eq('49h 40m') } + end + + context 'time_tracking_limit_to_hours setting is false' do + before do + stub_application_setting(time_tracking_limit_to_hours: false) + end + + it { expect(subject).to eq('1w 1d 1h 40m') } + end + end +end |