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

content_security_policy_helpers.rb « helpers « support « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 230075ead70fe19e7a194a5a9cbd7319c8027ad5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# frozen_string_literal: true

module ContentSecurityPolicyHelpers
  # 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).exactly(times).times
        .and_return(csp)
    end
  end
end