Skip to content

Commit

Permalink
fix: use consistent naming for configurations
Browse files Browse the repository at this point in the history
closes #1436
  • Loading branch information
zachdaniel committed Sep 5, 2024
1 parent e6a7006 commit 90332d0
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ if Mix.env() == :test do
Ash.Test.Support.PolicySimple.Domain
]

config :ash, :policy, no_filter_static_forbidden_reads?: false
config :ash, :policies, no_filter_static_forbidden_reads?: false

config :ash, :custom_expressions, [Ash.Test.Expressions.JaroDistance]

Expand Down
2 changes: 1 addition & 1 deletion lib/ash/policy/authorizer/authorizer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1559,7 +1559,7 @@ defmodule Ash.Policy.Authorizer do
defp forbidden_due_to_strict_policy?(authorizer) do
no_filter_static_forbidden_reads? =
Keyword.get(
Application.get_env(:ash, :policy, []),
Application.get_env(:ash, :policies, []),
:no_filter_static_forbidden_reads?,
true
)
Expand Down
2 changes: 1 addition & 1 deletion lib/ash/policy/filter_check.ex
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ defmodule Ash.Policy.FilterCheck do
|> then(fn expr ->
no_filter_static_forbidden_reads? =
Keyword.get(
Application.get_env(:ash, :policy, []),
Application.get_env(:ash, :policies, []),
:no_filter_static_forbidden_reads?,
true
)
Expand Down
10 changes: 8 additions & 2 deletions test/policy/complex_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@ defmodule Ash.Test.Policy.ComplexTest do
alias Ash.Test.Support.PolicyComplex.{Bio, Comment, Post, User}

setup do
Application.put_env(:ash, :policies, show_policy_breakdowns?: true)
old_env = Application.get_env(:ash, :policies, [])

Application.put_env(
:ash,
:policies,
Keyword.merge(old_env, show_policy_breakdowns?: true)
)

on_exit(fn ->
Application.delete_env(:ash, :policies)
Application.put_env(:ash, :policies, old_env)
end)

me = User.create!("me", %{email: "me@app.com", bio_text: "this is my bio"}, authorize?: false)
Expand Down
10 changes: 8 additions & 2 deletions test/policy/simple_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,16 @@ defmodule Ash.Test.Policy.SimpleTest do
end

setup do
Application.put_env(:ash, :policies, show_policy_breakdowns?: true)
old_env = Application.get_env(:ash, :policies, [])

Application.put_env(
:ash,
:policies,
Keyword.merge(old_env, show_policy_breakdowns?: true)
)

on_exit(fn ->
Application.delete_env(:ash, :policies)
Application.put_env(:ash, :policies, old_env)
end)

[
Expand Down

0 comments on commit 90332d0

Please sign in to comment.