mirror of
https://github.com/ash-project/ash_postgres.git
synced 2024-09-20 05:23:18 +12:00
test: add failing test for changing_attributes
check for create (#288)
This commit is contained in:
parent
d5c55f6b10
commit
74cead8749
2 changed files with 13 additions and 1 deletions
|
@ -12,7 +12,15 @@ defmodule AshPostgresTest do
|
|||
}
|
||||
end
|
||||
|
||||
test "filter policies are applied" do
|
||||
test "filter policies are applied in create" do
|
||||
assert_raise Ash.Error.Forbidden, fn ->
|
||||
AshPostgres.Test.Post
|
||||
|> Ash.Changeset.for_create(:create, %{title: "worst"})
|
||||
|> Ash.create!()
|
||||
end
|
||||
end
|
||||
|
||||
test "filter policies are applied in update" do
|
||||
post =
|
||||
AshPostgres.Test.Post
|
||||
|> Ash.Changeset.for_create(:create, %{title: "good"})
|
||||
|
|
|
@ -41,6 +41,10 @@ defmodule AshPostgres.Test.Post do
|
|||
authorize_if(relates_to_actor_via([:author, :authors_with_same_first_name]))
|
||||
authorize_unless(changing_attributes(title: [from: "good", to: "bad"]))
|
||||
end
|
||||
|
||||
policy action(:create) do
|
||||
authorize_unless(changing_attributes(title: [to: "worst"]))
|
||||
end
|
||||
end
|
||||
|
||||
field_policies do
|
||||
|
|
Loading…
Reference in a new issue