Skip to content
Snippets Groups Projects
Verified Commit b1ad788e authored by Rémy Coutable's avatar Rémy Coutable
Browse files

Fix deprecated RackAttack.throttled_response -> throttled_responder


Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 609631d4
No related branches found
No related tags found
1 merge request!89757Update Ruby Rack-related dependencies
......@@ -9,7 +9,7 @@
let(:fake_cache) { instance_double("Rack::Attack::Cache") }
before do
allow(fake_rack_attack).to receive(:throttled_response=)
allow(fake_rack_attack).to receive(:throttled_responder=)
allow(fake_rack_attack).to receive(:throttle)
allow(fake_rack_attack).to receive(:track)
allow(fake_rack_attack).to receive(:safelist)
......
......@@ -12,9 +12,9 @@ def self.configure(rack_attack)
rack_attack::Request.include(Gitlab::RackAttack::Request)
# This is Rack::Attack::DEFAULT_THROTTLED_RESPONSE, modified to allow a custom response
rack_attack.throttled_response = lambda do |env|
rack_attack.throttled_responder = lambda do |request|
throttled_headers = Gitlab::RackAttack.throttled_response_headers(
env['rack.attack.matched'], env['rack.attack.match_data']
request.env['rack.attack.matched'], request.env['rack.attack.match_data']
)
[429, { 'Content-Type' => 'text/plain' }.merge(throttled_headers), [Gitlab::Throttle.rate_limiting_response_text]]
end
......
......@@ -27,7 +27,7 @@
end
before do
allow(fake_rack_attack).to receive(:throttled_response=)
allow(fake_rack_attack).to receive(:throttled_responder=)
allow(fake_rack_attack).to receive(:throttle)
allow(fake_rack_attack).to receive(:track)
allow(fake_rack_attack).to receive(:safelist)
......@@ -48,7 +48,7 @@
it 'configures the throttle response' do
described_class.configure(fake_rack_attack)
expect(fake_rack_attack).to have_received(:throttled_response=).with(an_instance_of(Proc))
expect(fake_rack_attack).to have_received(:throttled_responder=).with(an_instance_of(Proc))
end
it 'configures the safelist' do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment