diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-09 15:06:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-09 15:06:13 +0300 |
commit | 0a850868dfb85086cba8320cee9dac4657dcae6c (patch) | |
tree | 40d17228fe23d9db7b861fe2a20d024d64c50323 /spec/support/shared_contexts | |
parent | 3744bcc0d10d24104e39985b6833a0ec51791c0a (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support/shared_contexts')
-rw-r--r-- | spec/support/shared_contexts/rack_attack_shared_context.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/support/shared_contexts/rack_attack_shared_context.rb b/spec/support/shared_contexts/rack_attack_shared_context.rb new file mode 100644 index 00000000000..c925f565226 --- /dev/null +++ b/spec/support/shared_contexts/rack_attack_shared_context.rb @@ -0,0 +1,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 |