Skip to content

Commit

Permalink
Add failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
santib committed Nov 8, 2024
1 parent 74517c3 commit 8a150d1
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions spec/rack_attack_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 8a150d1

Please sign in to comment.