From 8a150d1c26fc46b529254608f6285240e38053b0 Mon Sep 17 00:00:00 2001 From: Santiago Bartesaghi Date: Fri, 8 Nov 2024 14:05:45 -0300 Subject: [PATCH] Add failing test --- spec/rack_attack_spec.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/spec/rack_attack_spec.rb b/spec/rack_attack_spec.rb index 377ab852..54f2f1df 100644 --- a/spec/rack_attack_spec.rb +++ b/spec/rack_attack_spec.rb @@ -125,6 +125,19 @@ end end + if defined?(Redis) && defined?(ActiveSupport::Cache::RedisCacheStore) + it 'should delete rack attack keys' do + redis_cache_store = ActiveSupport::Cache::RedisCacheStore.new(namespace: 'ns') + redis_cache_store.write('key', 'value') + redis_cache_store.write("#{Rack::Attack.cache.prefix}::key", 'value') + Rack::Attack.cache.store = redis_cache_store + Rack::Attack.reset! + + _(redis_cache_store.read('key')).must_equal 'value' + _(redis_cache_store.read("#{Rack::Attack.cache.prefix}::key")).must_be_nil + end + end + if defined?(ActiveSupport::Cache::MemoryStore) it 'should delete rack attack keys' do memory_store = ActiveSupport::Cache::MemoryStore.new(namespace: 'ns')