summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/patch/chronic_duration_spec.rb
blob: 541037ec1a2043750966a5f3f5461ce8ba043c9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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