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

RSpec.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
    freeze_time { example.run }

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