diff options
Diffstat (limited to 'spec/support/helpers/content_security_policy_helpers.rb')
-rw-r--r-- | spec/support/helpers/content_security_policy_helpers.rb | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/spec/support/helpers/content_security_policy_helpers.rb b/spec/support/helpers/content_security_policy_helpers.rb index c9f15e65c74..230075ead70 100644 --- a/spec/support/helpers/content_security_policy_helpers.rb +++ b/spec/support/helpers/content_security_policy_helpers.rb @@ -1,20 +1,14 @@ # 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) + # Expecting 2 calls to current_content_security_policy by default: + # 1. call that's being tested + # 2. call in ApplicationController + def setup_csp_for_controller(controller_class, csp = ActionDispatch::ContentSecurityPolicy.new, 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 + expect(controller) + .to receive(:current_content_security_policy).exactly(times).times + .and_return(csp) end end end |