blob: bf0eaf80d3b1bef21d29aefd9fe69faebacff84a (
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::PollingInterval 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)
expect(headers['Poll-Interval']).to eq('-1')
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)
expect(headers['Poll-Interval']).to eq('3333')
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
|