Skip to content

Commit

Permalink
fix: reproduce issue around atomic updates & validations
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Apr 22, 2024
1 parent d26a189 commit ec91e2e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/atomics_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check failure on line 36 in test/atomics_test.exs

View workflow job for this annotation

GitHub Actions / ash-ci (15) / mix test

test an atomic validation is based on where it appears in the action (AshPostgres.AtomicsTest)

Check failure on line 36 in test/atomics_test.exs

View workflow job for this annotation

GitHub Actions / ash-ci (16) / mix test

test an atomic validation is based on where it appears in the action (AshPostgres.AtomicsTest)

Check failure on line 36 in test/atomics_test.exs

View workflow job for this annotation

GitHub Actions / ash-ci (14) / mix test

test an atomic validation is based on where it appears in the action (AshPostgres.AtomicsTest)
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
Expand Down
5 changes: 5 additions & 0 deletions test/support/resources/post.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ec91e2e

Please sign in to comment.