Skip to content

Commit 7e16537

Browse files
committed
add test clause ensuring that idempotent_additions? is only called once
1 parent 00ce0c1 commit 7e16537

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

spec/lib/secure_headers_spec.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,15 @@ module SecureHeaders
106106
expect(hash[CSP::HEADER_NAME]).to eq("default-src 'self'; script-src mycdn.com 'unsafe-inline' anothercdn.com")
107107
end
108108

109-
it "dups global configuration just once when overriding n times" do
109+
it "dups global configuration just once when overriding n times and only calls idempotent_additions? once" do
110110
Configuration.default do |config|
111111
config.csp = {
112112
default_src: %w('self')
113113
}
114114
end
115115

116+
expect(CSP).to receive(:idempotent_additions?).once
117+
116118
# before an override occurs, the env is empty
117119
expect(request.env[SECURE_HEADERS_CONFIG]).to be_nil
118120

@@ -123,6 +125,8 @@ module SecureHeaders
123125
SecureHeaders.override_content_security_policy_directives(request, script_src: %w(yet.anothercdn.com))
124126
current_config = SecureHeaders.config_for(request)
125127
expect(current_config).to be(new_config)
128+
129+
SecureHeaders.header_hash_for(request)
126130
end
127131

128132
it "overrides individual directives" do

0 commit comments

Comments
 (0)