BigW Consortium Gitlab

polling_interval_spec.rb 855 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
require 'spec_helper'

describe Gitlab::PollingInterval, lib: true do
  let(:polling_interval) { described_class }

  describe '.set_header' do
    let(:headers) { {} }
    let(:response) { double(headers: headers) }

    context 'when polling is disabled' do
      before do
        stub_application_setting(polling_interval_multiplier: 0)
      end

      it 'sets value to -1' do
        polling_interval.set_header(response, interval: 10_000)

18
        expect(headers['Poll-Interval']).to eq('-1')
19 20 21 22 23 24 25 26 27 28 29
      end
    end

    context 'when polling is enabled' do
      before do
        stub_application_setting(polling_interval_multiplier: 0.33333)
      end

      it 'applies modifier to base interval' do
        polling_interval.set_header(response, interval: 10_000)

30
        expect(headers['Poll-Interval']).to eq('3333')
31 32 33 34
      end
    end
  end
end