diff options
Diffstat (limited to 'spec/lib/gitlab/polling_interval_spec.rb')
-rw-r--r-- | spec/lib/gitlab/polling_interval_spec.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/lib/gitlab/polling_interval_spec.rb b/spec/lib/gitlab/polling_interval_spec.rb index 979164269bd..31569b2c51e 100644 --- a/spec/lib/gitlab/polling_interval_spec.rb +++ b/spec/lib/gitlab/polling_interval_spec.rb @@ -33,4 +33,36 @@ describe Gitlab::PollingInterval do end end end + + describe '.set_api_header' do + let(:context) { double(Grape::Endpoint) } + + before do + allow(context).to receive(:header) + end + + context 'when polling is disabled' do + before do + stub_application_setting(polling_interval_multiplier: 0) + end + + it 'sets value to -1' do + expect(context).to receive(:header).with('Poll-Interval', '-1') + + polling_interval.set_api_header(context, interval: 10_000) + 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 + expect(context).to receive(:header).with('Poll-Interval', '3333') + + polling_interval.set_api_header(context, interval: 10_000) + end + end + end end |