mirror of
https://github.com/ash-project/ash_postgres.git
synced 2024-09-20 05:23:18 +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`
34 lines
856 B
Elixir
34 lines
856 B
Elixir
defmodule AshPostgres.EmbeddableResourceTest do
|
|
@moduledoc false
|
|
use AshPostgres.RepoCase, async: false
|
|
alias AshPostgres.Test.{Author, Bio, Post}
|
|
|
|
require Ash.Query
|
|
|
|
setup do
|
|
post =
|
|
Post
|
|
|> Ash.Changeset.for_create(:create, %{title: "title"})
|
|
|> Ash.create!()
|
|
|
|
%{post: post}
|
|
end
|
|
|
|
test "calculations can load json", %{post: post} do
|
|
assert %{calc_returning_json: %AshPostgres.Test.Money{amount: 100, currency: :usd}} =
|
|
Ash.load!(post, :calc_returning_json)
|
|
end
|
|
|
|
test "embeds with list attributes set to nil are loaded as nil" do
|
|
author =
|
|
Author
|
|
|> Ash.Changeset.for_create(:create, %{bio: %Bio{list_of_strings: nil}})
|
|
|> Ash.create!()
|
|
|
|
assert is_nil(author.bio.list_of_strings)
|
|
|
|
author = Ash.reload!(author)
|
|
|
|
assert is_nil(author.bio.list_of_strings)
|
|
end
|
|
end
|