mirror of
https://github.com/ash-project/ash_postgres.git
synced 2024-09-20 05:23:18 +12:00
test: add failing test to demo bug with changeset loading related data (#200)
This commit is contained in:
parent
5006a195bd
commit
745a3b8264
2 changed files with 11 additions and 0 deletions
|
@ -7,11 +7,21 @@ defmodule AshPostgres.ManualUpdateTest do
|
|||
|> Ash.Changeset.new(%{title: "match"})
|
||||
|> AshPostgres.Test.Api.create!()
|
||||
|
||||
AshPostgres.Test.Comment
|
||||
|> Ash.Changeset.new(%{title: "_"})
|
||||
|> Ash.Changeset.manage_relationship(:post, post, type: :append_and_remove)
|
||||
|> AshPostgres.Test.Api.create!()
|
||||
|
||||
post =
|
||||
post
|
||||
|> Ash.Changeset.for_update(:manual_update)
|
||||
|> AshPostgres.Test.Api.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
|
||||
|
|
|
@ -453,6 +453,7 @@ defmodule AshPostgres.Test.Post.ManualUpdate do
|
|||
changeset.data
|
||||
|> Ash.Changeset.for_update(:update, changeset.attributes)
|
||||
|> Ash.Changeset.force_change_attribute(:title, "manual")
|
||||
|> Ash.Changeset.load(:comments)
|
||||
|> AshPostgres.Test.Api.update!()
|
||||
}
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue