Skip to content

Commit

Permalink
Appease credo
Browse files Browse the repository at this point in the history
  • Loading branch information
mbramson committed Nov 4, 2019
1 parent 2abca98 commit 5641623
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion lib/content_security_policy/plug/add_source_value.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ defmodule ContentSecurityPolicy.Plug.AddSourceValue do
alias ContentSecurityPolicy.Directive
alias ContentSecurityPolicy.Policy

def init([]), do: raise_no_arguments_error()
def init(opts) do
Enum.each(opts, fn {directive, _source_value} ->
Directive.validate_directive!(directive)
Expand Down Expand Up @@ -69,7 +70,7 @@ defmodule ContentSecurityPolicy.Plug.AddSourceValue do
"""
end

defp raise_no_arguments_error() do
defp raise_no_arguments_error do
raise ArgumentError, """
No directive and source value supplied to the
`ContentSecurityPolicy.Plug.AddSourceValue` plug.
Expand Down
8 changes: 4 additions & 4 deletions test/content_security_policy/plug/add_source_value_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ defmodule ContentSecurityPolicy.Plug.AddSourceValueTest do

describe "call/2" do
property "adds source values to corresponding directives" do
check all valid_directives_with_source_values <-
check all valid_directives_with_source_values <-
TestHelpers.list_of_valid_directive_source_value_pairs_generator()
do
conn = send_response(valid_directives_with_source_values)
Expand All @@ -31,18 +31,18 @@ defmodule ContentSecurityPolicy.Plug.AddSourceValueTest do
assert {:ok, regex_for_this_pair} = Regex.compile(match)
assert csp_header =~ regex_for_this_pair
end)
end
end
end

test "raises an error if given an invalid directive" do
assert_raise(ArgumentError, ~r/Invalid directive/, fn ->
conn = send_response(not_a_directive: "doesnt matter")
send_response(not_a_directive: "doesnt matter")
end)
end

test "raises an error if given no directive source value pairs" do
assert_raise(ArgumentError, ~r/No directive and source value supplied/, fn ->
conn = send_response([])
send_response([])
end)
end
end
Expand Down

0 comments on commit 5641623

Please sign in to comment.