summaryrefslogtreecommitdiff
path: root/spec/support/shared_contexts/rack_attack_shared_context.rb
blob: c925f565226323ca9ee414a5aa5c0157b1d55a8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
# frozen_string_literal: true

shared_context 'rack attack cache store' do
  around do |example|
    # Instead of test environment's :null_store so the throttles can increment
    Rack::Attack.cache.store = ActiveSupport::Cache::MemoryStore.new

    # Make time-dependent tests deterministic
    Timecop.freeze { example.run }

    Rack::Attack.cache.store = Rails.cache
  end
end