summaryrefslogtreecommitdiff
path: root/spec/support/shared_contexts/rack_attack_shared_context.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-22 11:31:16 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-22 11:31:16 +0000
commit905c1110b08f93a19661cf42a276c7ea90d0a0ff (patch)
tree756d138db422392c00471ab06acdff92c5a9b69c /spec/support/shared_contexts/rack_attack_shared_context.rb
parent50d93f8d1686950fc58dda4823c4835fd0d8c14b (diff)
downloadgitlab-ce-905c1110b08f93a19661cf42a276c7ea90d0a0ff.tar.gz
Add latest changes from gitlab-org/gitlab@12-4-stable-ee
Diffstat (limited to 'spec/support/shared_contexts/rack_attack_shared_context.rb')
-rw-r--r--spec/support/shared_contexts/rack_attack_shared_context.rb13
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