mirror of
https://github.com/ash-project/ash_postgres.git
synced 2024-09-20 21:43:12 +12:00
37cc01957d
* WIP * chore: fix mix.lock merge issues * improvement: upgrade to 3.0 * chore: remove `repo.to_tenant` * chore: continue removal of unnecessary helper * chore: use `Ash.ToTenant`
27 lines
803 B
Elixir
27 lines
803 B
Elixir
defmodule AshPostgres.ManualUpdateTest do
|
|
use AshPostgres.RepoCase, async: true
|
|
|
|
test "Manual update defined in a module to update an attribute" do
|
|
post =
|
|
AshPostgres.Test.Post
|
|
|> Ash.Changeset.for_create(:create, %{title: "match"})
|
|
|> Ash.create!()
|
|
|
|
AshPostgres.Test.Comment
|
|
|> Ash.Changeset.for_create(:create, %{title: "_"})
|
|
|> Ash.Changeset.manage_relationship(:post, post, type: :append_and_remove)
|
|
|> Ash.create!()
|
|
|
|
post =
|
|
post
|
|
|> Ash.Changeset.for_update(:manual_update)
|
|
|> Ash.update!()
|
|
|
|
assert post.title == "manual"
|
|
|
|
# The manual update has a call to Ash.Changeset.load that should
|
|
# cause the comments to be loaded
|
|
assert Ash.Resource.loaded?(post, :comments)
|
|
assert Enum.count(post.comments) == 1
|
|
end
|
|
end
|