2019-10-09 12:06:13 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-01-21 03:08:37 +00:00
|
|
|
RSpec.shared_context 'rack attack cache store' do
|
2019-10-09 12:06:13 +00:00
|
|
|
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
|