blob: c9f15e65c74499f0ffc0d2de6c0e361fd2f47ee1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
|