ash_postgres/test/ash_postgres_test.exs

41 lines
1,013 B
Elixir
Raw Normal View History

2019-12-05 03:58:20 +13:00
defmodule AshPostgresTest do
2022-12-01 14:59:18 +13:00
use AshPostgres.RepoCase, async: false
test "transaction metadata is given to on_transaction_begin" do
AshPostgres.Test.Post
|> Ash.Changeset.for_create(:create, %{title: "title"})
|> Ash.create!()
assert_receive %{
type: :create,
metadata: %{action: :create, actor: nil, resource: AshPostgres.Test.Post}
}
end
2024-02-15 07:56:58 +13:00
2024-02-16 04:54:20 +13:00
test "filter policies are applied" do
2024-02-15 07:56:58 +13:00
post =
AshPostgres.Test.Post
|> Ash.Changeset.for_create(:create, %{title: "good"})
|> Ash.create!()
2024-02-15 07:56:58 +13:00
assert_raise Ash.Error.Forbidden, fn ->
post
2024-02-16 04:54:20 +13:00
|> Ash.Changeset.for_update(:update, %{title: "bad"},
authorize?: true,
actor: nil,
2024-02-16 04:54:20 +13:00
actor: %{id: Ash.UUID.generate()}
)
|> Ash.update!(
authorize?: true,
actor: nil
)
|> Map.get(:title)
end
# post
# |> Ash.Changeset.for_update(:update, %{title: "okay"}, authorize?: true)
# |> Ash.update!()
# |> Map.get(:title)
2024-02-15 07:56:58 +13:00
end
2019-10-07 09:36:18 +13:00
end