Commit d8703071 authored by Michael Kozono's avatar Michael Kozono Committed by Francisco Lopez

Allow throttling code in test environment

This code should not break other tests because the rate limits are off by default.
parent 143369e4
......@@ -21,7 +21,6 @@ class Rack::Attack
{ limit: limit_proc, period: period_proc }
end
def self.define_throttles
throttle('throttle_unauthenticated', throttle_unauthenticated_options) do |req|
settings.throttle_unauthenticated_enabled &&
req.unauthenticated? &&
......@@ -39,9 +38,6 @@ class Rack::Attack
req.web_request? &&
req.authenticated_user_id
end
end
define_throttles unless Rails.env.test?
class Request
def unauthenticated?
......
......@@ -4,9 +4,6 @@ describe Rack::Attack do
let(:settings) { Gitlab::CurrentSettings.current_application_settings }
before do
# Ensure throttles are defined, because this is normally skipped for tests
described_class.define_throttles
# Instead of test environment's :null_store
Rack::Attack.cache.store = ActiveSupport::Cache::MemoryStore.new
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment