Skip to content

Commit

Permalink
Fix GovukContentSecurityPolicy test
Browse files Browse the repository at this point in the history
The test started failing because Rails now prevents meaningless assignments to
a configuration key by raising NoMethodError.  See:
rails/rails@265bfad

```
  GovukContentSecurityPolicy.configure creates a policy
     Failure/Error: Rails.application.config.content_security_policy = nil

     NoMethodError:
       Cannot assign to `content_security_policy`, it is a configuration method

                   raise NoMethodError.new("Cannot assign to `#{key}`, it is a configuration method")
                   ^^^^^
     # ./spec/lib/govuk_content_security_policy_spec.rb:14:in `block (3 levels) in <top (required)>'
```
  • Loading branch information
AgaDufrat committed Oct 5, 2023
1 parent 6438507 commit 6c709b2
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions spec/lib/govuk_content_security_policy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@

describe ".configure" do
it "creates a policy" do
Rails.application.config.content_security_policy = nil

expect { GovukContentSecurityPolicy.configure }
.to change { Rails.application.config.content_security_policy }
.from(nil)
.to(an_instance_of(ActionDispatch::ContentSecurityPolicy))
end

Expand Down

0 comments on commit 6c709b2

Please sign in to comment.