mirror of
https://github.com/ash-project/ash_postgres.git
synced 2024-09-20 05:23:18 +12:00
fix: reproduce issue around atomic updates & validations
This commit is contained in:
parent
d26a189946
commit
ec91e2ee9b
2 changed files with 17 additions and 0 deletions
|
@ -33,6 +33,18 @@ defmodule AshPostgres.AtomicsTest do
|
|||
|> Ash.update!()
|
||||
end
|
||||
|
||||
test "an atomic validation is based on where it appears in the action" do
|
||||
post =
|
||||
Post
|
||||
|> Ash.Changeset.for_create(:create, %{title: "bar"})
|
||||
|> Ash.create!()
|
||||
|
||||
# just asserting that there is no exception here
|
||||
post
|
||||
|> Ash.Changeset.for_update(:change_title_to_foo_unless_its_already_foo)
|
||||
|> Ash.update!()
|
||||
end
|
||||
|
||||
test "an atomic works with a datetime" do
|
||||
post =
|
||||
Post
|
||||
|
|
|
@ -113,6 +113,11 @@ defmodule AshPostgres.Test.Post do
|
|||
require_atomic?(false)
|
||||
end
|
||||
|
||||
update :change_title_to_foo_unless_its_already_foo do
|
||||
validate attribute_does_not_equal(:title, "foo")
|
||||
change set_attribute(:title, "foo")
|
||||
end
|
||||
|
||||
read :title_is_foo do
|
||||
filter(expr(title == "foo"))
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue