diff options
author | Adam Niedzielski <adamsunday@gmail.com> | 2017-04-03 15:17:04 +0200 |
---|---|---|
committer | Adam Niedzielski <adamsunday@gmail.com> | 2017-04-03 15:17:04 +0200 |
commit | 9543025e88d3d0fe298e95330b8d38802da50cc6 (patch) | |
tree | e96e1a10a4ba6cba5cade8cd959b3894b8e67cd8 /spec/lib/gitlab/polling_interval_spec.rb | |
parent | 2faf955c241ce7e99111f8fd0cae2e7ab6167e5a (diff) | |
download | gitlab-ce-9543025e88d3d0fe298e95330b8d38802da50cc6.tar.gz |
Introduce "polling_interval_multiplier" as application setting
Implement module for setting "Poll-Interval" response header.
Return 429 in ETag caching middleware when polling is disabled.
Diffstat (limited to 'spec/lib/gitlab/polling_interval_spec.rb')
-rw-r--r-- | spec/lib/gitlab/polling_interval_spec.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/lib/gitlab/polling_interval_spec.rb b/spec/lib/gitlab/polling_interval_spec.rb new file mode 100644 index 00000000000..56c2847e26a --- /dev/null +++ b/spec/lib/gitlab/polling_interval_spec.rb @@ -0,0 +1,34 @@ +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) + + 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 +end |