ash_postgres/test/ash_postgres_test.exs

37 lines
969 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.new(%{title: "title"})
|> AshPostgres.Test.Api.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.new(%{title: "good"})
|> AshPostgres.Test.Api.create!()
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: %{id: Ash.UUID.generate()}
)
|> AshPostgres.Test.Api.update!()
|> Map.get(:title)
end
2024-02-15 07:56:58 +13:00
post
|> Ash.Changeset.for_update(:update, %{title: "okay"}, authorize?: true)
2024-02-15 07:56:58 +13:00
|> AshPostgres.Test.Api.update!()
|> Map.get(:title)
end
2019-10-07 09:36:18 +13:00
end