File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,15 @@ defmodule AshPostgresTest do
12
12
}
13
13
end
14
14
15
- test "filter policies are applied" do
15
+ test "filter policies are applied in create" do
16
+ assert_raise Ash.Error.Forbidden , fn ->
17
+ AshPostgres.Test.Post
18
+ |> Ash.Changeset . for_create ( :create , % { title: "worst" } )
19
+ |> Ash . create! ( )
20
+ end
21
+ end
22
+
23
+ test "filter policies are applied in update" do
16
24
post =
17
25
AshPostgres.Test.Post
18
26
|> Ash.Changeset . for_create ( :create , % { title: "good" } )
Original file line number Diff line number Diff line change @@ -41,6 +41,10 @@ defmodule AshPostgres.Test.Post do
41
41
authorize_if ( relates_to_actor_via ( [ :author , :authors_with_same_first_name ] ) )
42
42
authorize_unless ( changing_attributes ( title: [ from: "good" , to: "bad" ] ) )
43
43
end
44
+
45
+ policy action ( :create ) do
46
+ authorize_unless ( changing_attributes ( title: [ to: "worst" ] ) )
47
+ end
44
48
end
45
49
46
50
field_policies do
You can’t perform that action at this time.
0 commit comments