debian-mirror-gitlab/spec/support/shared_contexts/rack_attack_shared_context.rb
2020-03-13 15:44:24 +05:30

14 lines
387 B
Ruby

# 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
Timecop.freeze { example.run }
Rack::Attack.cache.store = Rails.cache
end
end