From a99722bf4bca9ca89f73ff4ab76c07e74dd9abc0 Mon Sep 17 00:00:00 2001 From: Gonzalo Rodriguez Date: Fri, 18 May 2018 18:23:59 -0300 Subject: [PATCH] Avoid user confusion by renaming .clear! to .clear_configuration --- lib/rack/attack.rb | 7 ++++++- spec/spec_helper.rb | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/rack/attack.rb b/lib/rack/attack.rb index c7596ef..8334dc6 100644 --- a/lib/rack/attack.rb +++ b/lib/rack/attack.rb @@ -120,12 +120,17 @@ class Rack::Attack @cache ||= Cache.new end - def clear! + def clear_configuration @safelists, @blocklists, @throttles, @tracks = {}, {}, {}, {} @ip_blocklists = [] @ip_safelists = [] end + def clear! + warn "[DEPRECATION] Rack::Attack.clear! is deprecated. Please use Rack::Attack.clear_configuration instead" + clear_configuration + end + def blacklisted_response=(res) warn "[DEPRECATION] 'Rack::Attack.blacklisted_response=' is deprecated. Please use 'blocklisted_response=' instead." self.blocklisted_response = res diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8f8a71d..3f19b8f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -28,7 +28,7 @@ class MiniTest::Spec end after do - Rack::Attack.clear! + Rack::Attack.clear_configuration Rack::Attack.instance_variable_set(:@cache, nil) Rack::Attack.throttled_response = @_original_throttled_response