Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-02-18 21:18:16 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-02-18 21:18:16 +0300
commit9c042f0dada432de0e4144db50fd52f1d53b78c6 (patch)
treea99954bec23f9bce0bfec8245d965a9daeacf60f /spec/support/helpers/content_security_policy_helpers.rb
parent19ab203bec41ca29cecb3f2da23c55329bcea50e (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support/helpers/content_security_policy_helpers.rb')
-rw-r--r--spec/support/helpers/content_security_policy_helpers.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/support/helpers/content_security_policy_helpers.rb b/spec/support/helpers/content_security_policy_helpers.rb
new file mode 100644
index 00000000000..c9f15e65c74
--- /dev/null
+++ b/spec/support/helpers/content_security_policy_helpers.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+module ContentSecurityPolicyHelpers
+ # Expecting 2 calls to current_content_security_policy by default, once for
+ # the call that's being tested and once for the call in ApplicationController
+ def setup_csp_for_controller(controller_class, times = 2)
+ expect_next_instance_of(controller_class) do |controller|
+ expect(controller).to receive(:current_content_security_policy)
+ .and_return(ActionDispatch::ContentSecurityPolicy.new).exactly(times).times
+ end
+ end
+
+ # Expecting 2 calls to current_content_security_policy by default, once for
+ # the call that's being tested and once for the call in ApplicationController
+ def setup_existing_csp_for_controller(controller_class, csp, times = 2)
+ expect_next_instance_of(controller_class) do |controller|
+ expect(controller).to receive(:current_content_security_policy).and_return(csp).exactly(times).times
+ end
+ end
+end