summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/rack_attack_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/rack_attack_spec.rb')
-rw-r--r--spec/lib/gitlab/rack_attack_spec.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/spec/lib/gitlab/rack_attack_spec.rb b/spec/lib/gitlab/rack_attack_spec.rb
index 8f03905e08d..39ea02bad8b 100644
--- a/spec/lib/gitlab/rack_attack_spec.rb
+++ b/spec/lib/gitlab/rack_attack_spec.rb
@@ -5,8 +5,8 @@ require 'spec_helper'
RSpec.describe Gitlab::RackAttack, :aggregate_failures do
describe '.configure' do
let(:fake_rack_attack) { class_double("Rack::Attack") }
- let(:fake_rack_attack_request) { class_double("Rack::Attack::Request") }
- let(:fake_cache) { instance_double("Rack::Attack::Cache") }
+ let(:fake_rack_attack_request) { class_double(Rack::Attack::Request) }
+ let(:fake_cache) { instance_double(Rack::Attack::Cache) }
let(:throttles) do
{
@@ -27,9 +27,6 @@ RSpec.describe Gitlab::RackAttack, :aggregate_failures do
end
before do
- stub_const("Rack::Attack", fake_rack_attack)
- stub_const("Rack::Attack::Request", fake_rack_attack_request)
-
allow(fake_rack_attack).to receive(:throttled_response=)
allow(fake_rack_attack).to receive(:throttle)
allow(fake_rack_attack).to receive(:track)
@@ -37,6 +34,9 @@ RSpec.describe Gitlab::RackAttack, :aggregate_failures do
allow(fake_rack_attack).to receive(:blocklist)
allow(fake_rack_attack).to receive(:cache).and_return(fake_cache)
allow(fake_cache).to receive(:store=)
+
+ fake_rack_attack.const_set('Request', fake_rack_attack_request)
+ stub_const("Rack::Attack", fake_rack_attack)
end
it 'extends the request class' do
@@ -78,7 +78,7 @@ RSpec.describe Gitlab::RackAttack, :aggregate_failures do
it 'configures tracks and throttles with a selected set of dry-runs' do
dry_run_throttles = throttles.each_key.first(2)
- regular_throttles = throttles.keys[2..-1]
+ regular_throttles = throttles.keys[2..]
stub_env('GITLAB_THROTTLE_DRY_RUN', dry_run_throttles.join(','))
described_class.configure(fake_rack_attack)