From ef83659b324e0a2f1d83bfb2a0d3760e433c1213 Mon Sep 17 00:00:00 2001 From: "Barnabas Jovanovics (aider)" Date: Wed, 23 Apr 2025 13:50:03 +0200 Subject: [PATCH 1/9] test: add aggregate validation test for multitenancy context --- test/multitenancy_test.exs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/test/multitenancy_test.exs b/test/multitenancy_test.exs index 73f9cb52..65f6e825 100644 --- a/test/multitenancy_test.exs +++ b/test/multitenancy_test.exs @@ -135,6 +135,41 @@ defmodule AshPostgres.Test.MultitenancyTest do assert [_] = CompositeKeyPost |> Ash.Query.set_tenant(org1) |> Ash.read!() end + test "aggregate validations work with multitenancy", %{org1: org1} do + # Create a post in org1 + post = + Post + |> Ash.Changeset.for_create(:create, %{name: "foo"}) + |> Ash.Changeset.set_tenant(org1) + |> Ash.create!() + + # Create a user for the post + User + |> Ash.Changeset.for_create(:create, %{name: "commenter"}) + |> Ash.Changeset.set_tenant(org1) + |> Ash.create!() + + # Test that aggregate validation works with tenant context + assert_raise Ash.Error.Invalid, ~r/Can only update if Post has no users/, fn -> + post + |> Ash.Changeset.new() + |> Ash.Changeset.put_context(:aggregate, :exists) + |> Ash.Changeset.for_update(:update_if_no_users, %{name: "updated"}) + |> Ash.Changeset.set_tenant(org1) + |> Ash.update!() + end + + # Test non-atomic validation + assert_raise Ash.Error.Invalid, ~r/Can only update if Post has no users/, fn -> + post + |> Ash.Changeset.new() + |> Ash.Changeset.put_context(:aggregate, :exists) + |> Ash.Changeset.for_update(:update_if_no_users_non_atomic, %{name: "updated"}) + |> Ash.Changeset.set_tenant(org1) + |> Ash.update!() + end + end + test "loading attribute multitenant resources from context multitenant resources works" do org = Org From 6ba12ab98fa0aa1c7c76155b12066927199a1c36 Mon Sep 17 00:00:00 2001 From: "Barnabas Jovanovics (aider)" Date: Wed, 23 Apr 2025 13:52:36 +0200 Subject: [PATCH 2/9] refactor: modify multitenancy test to use linked posts for aggregate validation --- test/multitenancy_test.exs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/test/multitenancy_test.exs b/test/multitenancy_test.exs index 65f6e825..0b983be8 100644 --- a/test/multitenancy_test.exs +++ b/test/multitenancy_test.exs @@ -143,28 +143,36 @@ defmodule AshPostgres.Test.MultitenancyTest do |> Ash.Changeset.set_tenant(org1) |> Ash.create!() - # Create a user for the post - User - |> Ash.Changeset.for_create(:create, %{name: "commenter"}) + # Create a linked post for the post + linked_post = + Post + |> Ash.Changeset.for_create(:create, %{name: "linked post"}) + |> Ash.Changeset.set_tenant(org1) + |> Ash.create!() + + # Link the posts + post + |> Ash.Changeset.new() + |> Ash.Changeset.manage_relationship(:linked_posts, linked_post, type: :append_and_remove) |> Ash.Changeset.set_tenant(org1) - |> Ash.create!() + |> Ash.update!() # Test that aggregate validation works with tenant context - assert_raise Ash.Error.Invalid, ~r/Can only update if Post has no users/, fn -> + assert_raise Ash.Error.Invalid, ~r/Can only update if Post has no linked posts/, fn -> post |> Ash.Changeset.new() |> Ash.Changeset.put_context(:aggregate, :exists) - |> Ash.Changeset.for_update(:update_if_no_users, %{name: "updated"}) + |> Ash.Changeset.for_update(:update_if_no_linked_posts, %{name: "updated"}) |> Ash.Changeset.set_tenant(org1) |> Ash.update!() end # Test non-atomic validation - assert_raise Ash.Error.Invalid, ~r/Can only update if Post has no users/, fn -> + assert_raise Ash.Error.Invalid, ~r/Can only update if Post has no linked posts/, fn -> post |> Ash.Changeset.new() |> Ash.Changeset.put_context(:aggregate, :exists) - |> Ash.Changeset.for_update(:update_if_no_users_non_atomic, %{name: "updated"}) + |> Ash.Changeset.for_update(:update_if_no_linked_posts_non_atomic, %{name: "updated"}) |> Ash.Changeset.set_tenant(org1) |> Ash.update!() end From 1a1d1242fc9b4ce5110ede7f460b82fa38a5d62f Mon Sep 17 00:00:00 2001 From: "Barnabas Jovanovics (aider)" Date: Wed, 23 Apr 2025 14:18:06 +0200 Subject: [PATCH 3/9] test: enhance multitenancy aggregate validation test coverage --- test/multitenancy_test.exs | 41 ++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/test/multitenancy_test.exs b/test/multitenancy_test.exs index 0b983be8..bfe1e6d2 100644 --- a/test/multitenancy_test.exs +++ b/test/multitenancy_test.exs @@ -135,26 +135,33 @@ defmodule AshPostgres.Test.MultitenancyTest do assert [_] = CompositeKeyPost |> Ash.Query.set_tenant(org1) |> Ash.read!() end - test "aggregate validations work with multitenancy", %{org1: org1} do + test "aggregate validations work with multitenancy", %{org1: org1, org2: org2} do # Create a post in org1 post = Post |> Ash.Changeset.for_create(:create, %{name: "foo"}) - |> Ash.Changeset.set_tenant(org1) + |> Ash.Changeset.set_tenant("org_" <> org1.id) |> Ash.create!() - # Create a linked post for the post + # Create a linked post for the post in org1 linked_post = Post |> Ash.Changeset.for_create(:create, %{name: "linked post"}) - |> Ash.Changeset.set_tenant(org1) + |> Ash.Changeset.set_tenant("org_" <> org1.id) + |> Ash.create!() + + # Create a linked post in org2 - should not affect validation in org1 + _org2_post = + Post + |> Ash.Changeset.for_create(:create, %{name: "org2 post"}) + |> Ash.Changeset.set_tenant("org_" <> org2.id) |> Ash.create!() - # Link the posts + # Link the posts in org1 post |> Ash.Changeset.new() |> Ash.Changeset.manage_relationship(:linked_posts, linked_post, type: :append_and_remove) - |> Ash.Changeset.set_tenant(org1) + |> Ash.Changeset.set_tenant("org_" <> org1.id) |> Ash.update!() # Test that aggregate validation works with tenant context @@ -163,7 +170,7 @@ defmodule AshPostgres.Test.MultitenancyTest do |> Ash.Changeset.new() |> Ash.Changeset.put_context(:aggregate, :exists) |> Ash.Changeset.for_update(:update_if_no_linked_posts, %{name: "updated"}) - |> Ash.Changeset.set_tenant(org1) + |> Ash.Changeset.set_tenant("org_" <> org1.id) |> Ash.update!() end @@ -173,9 +180,27 @@ defmodule AshPostgres.Test.MultitenancyTest do |> Ash.Changeset.new() |> Ash.Changeset.put_context(:aggregate, :exists) |> Ash.Changeset.for_update(:update_if_no_linked_posts_non_atomic, %{name: "updated"}) - |> Ash.Changeset.set_tenant(org1) + |> Ash.Changeset.set_tenant("org_" <> org1.id) |> Ash.update!() end + + # Verify that a post with no linked posts in org2 can be updated + org2_post = + Post + |> Ash.Changeset.for_create(:create, %{name: "updateable"}) + |> Ash.Changeset.set_tenant("org_" <> org2.id) + |> Ash.create!() + + # This should succeed since the post has no linked posts in org2 + updated_post = + org2_post + |> Ash.Changeset.new() + |> Ash.Changeset.put_context(:aggregate, :exists) + |> Ash.Changeset.for_update(:update_if_no_linked_posts, %{name: "updated"}) + |> Ash.Changeset.set_tenant("org_" <> org2.id) + |> Ash.update!() + + assert updated_post.name == "updated" end test "loading attribute multitenant resources from context multitenant resources works" do From bca05b7ef1c5f7e7f3d4c635379ba784c0ce6b01 Mon Sep 17 00:00:00 2001 From: "Barnabas Jovanovics (aider)" Date: Wed, 23 Apr 2025 14:44:46 +0200 Subject: [PATCH 4/9] feat: add HasNoLinkedPosts validation and update actions to Post resource --- test/support/multitenancy/resources/post.ex | 32 +++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/test/support/multitenancy/resources/post.ex b/test/support/multitenancy/resources/post.ex index e097fffb..c0d7a7bc 100644 --- a/test/support/multitenancy/resources/post.ex +++ b/test/support/multitenancy/resources/post.ex @@ -1,3 +1,21 @@ +defmodule HasNoLinkedPosts do + @moduledoc false + use Ash.Resource.Validation + + def atomic(changeset, _opts, context) do + condition = expr(exists(linked_posts, true)) + + [ + {:atomic, [], condition, + expr( + error(^Ash.Error.Changes.InvalidChanges, %{ + message: ^context.message || "Post has linked posts" + }) + )} + ] + end +end + defmodule AshPostgres.MultitenancyTest.Post do @moduledoc false use Ash.Resource, @@ -27,6 +45,20 @@ defmodule AshPostgres.MultitenancyTest.Post do defaults([:create, :read, :update, :destroy]) update(:update_with_policy) + + update :update_if_no_linked_posts do + validate HasNoLinkedPosts do + message "Can only update if Post has no linked posts" + end + end + + update :update_if_no_linked_posts_non_atomic do + require_atomic?(false) + + validate HasNoLinkedPosts do + message "Can only update if Post has no linked posts" + end + end end postgres do From bfa17e6af2bd8a42b4071d3df4269f5b06afebfc Mon Sep 17 00:00:00 2001 From: "Barnabas Jovanovics (aider)" Date: Wed, 23 Apr 2025 14:49:52 +0200 Subject: [PATCH 5/9] feat: add destroy actions with linked posts validation for multitenancy test --- test/multitenancy_test.exs | 35 +++++++++++++++++++++ test/support/multitenancy/resources/post.ex | 14 +++++++++ 2 files changed, 49 insertions(+) diff --git a/test/multitenancy_test.exs b/test/multitenancy_test.exs index bfe1e6d2..6400e3e2 100644 --- a/test/multitenancy_test.exs +++ b/test/multitenancy_test.exs @@ -184,6 +184,26 @@ defmodule AshPostgres.Test.MultitenancyTest do |> Ash.update!() end + # Test destroy with atomic validation + assert_raise Ash.Error.Invalid, ~r/Can only delete if Post has no linked posts/, fn -> + post + |> Ash.Changeset.new() + |> Ash.Changeset.put_context(:aggregate, :exists) + |> Ash.Changeset.for_destroy(:destroy_if_no_linked_posts, %{}) + |> Ash.Changeset.set_tenant("org_" <> org1.id) + |> Ash.destroy!() + end + + # Test destroy with non-atomic validation + assert_raise Ash.Error.Invalid, ~r/Can only delete if Post has no linked posts/, fn -> + post + |> Ash.Changeset.new() + |> Ash.Changeset.put_context(:aggregate, :exists) + |> Ash.Changeset.for_destroy(:destroy_if_no_linked_posts_non_atomic, %{}) + |> Ash.Changeset.set_tenant("org_" <> org1.id) + |> Ash.destroy!() + end + # Verify that a post with no linked posts in org2 can be updated org2_post = Post @@ -201,6 +221,21 @@ defmodule AshPostgres.Test.MultitenancyTest do |> Ash.update!() assert updated_post.name == "updated" + + # Test that a post with no linked posts in org2 can be destroyed + org2_post_for_destroy = + Post + |> Ash.Changeset.for_create(:create, %{name: "destroyable"}) + |> Ash.Changeset.set_tenant("org_" <> org2.id) + |> Ash.create!() + + # This should succeed since the post has no linked posts in org2 + org2_post_for_destroy + |> Ash.Changeset.new() + |> Ash.Changeset.put_context(:aggregate, :exists) + |> Ash.Changeset.for_destroy(:destroy_if_no_linked_posts, %{}) + |> Ash.Changeset.set_tenant("org_" <> org2.id) + |> Ash.destroy!() end test "loading attribute multitenant resources from context multitenant resources works" do diff --git a/test/support/multitenancy/resources/post.ex b/test/support/multitenancy/resources/post.ex index c0d7a7bc..1c57119a 100644 --- a/test/support/multitenancy/resources/post.ex +++ b/test/support/multitenancy/resources/post.ex @@ -59,6 +59,20 @@ defmodule AshPostgres.MultitenancyTest.Post do message "Can only update if Post has no linked posts" end end + + destroy :destroy_if_no_linked_posts do + validate HasNoLinkedPosts do + message "Can only delete if Post has no linked posts" + end + end + + destroy :destroy_if_no_linked_posts_non_atomic do + require_atomic?(false) + + validate HasNoLinkedPosts do + message "Can only delete if Post has no linked posts" + end + end end postgres do From 4d496eebe8510035716d584b65403549ffce6215 Mon Sep 17 00:00:00 2001 From: "Barnabas Jovanovics (aider)" Date: Wed, 23 Apr 2025 14:52:37 +0200 Subject: [PATCH 6/9] refactor: split multitenancy aggregate validation tests into focused test cases --- test/multitenancy_test.exs | 131 ++++++++++++++++++++++++++++++++++--- 1 file changed, 121 insertions(+), 10 deletions(-) diff --git a/test/multitenancy_test.exs b/test/multitenancy_test.exs index 6400e3e2..c9096393 100644 --- a/test/multitenancy_test.exs +++ b/test/multitenancy_test.exs @@ -135,7 +135,7 @@ defmodule AshPostgres.Test.MultitenancyTest do assert [_] = CompositeKeyPost |> Ash.Query.set_tenant(org1) |> Ash.read!() end - test "aggregate validations work with multitenancy", %{org1: org1, org2: org2} do + test "aggregate validation prevents update with linked posts", %{org1: org1} do # Create a post in org1 post = Post @@ -150,13 +150,6 @@ defmodule AshPostgres.Test.MultitenancyTest do |> Ash.Changeset.set_tenant("org_" <> org1.id) |> Ash.create!() - # Create a linked post in org2 - should not affect validation in org1 - _org2_post = - Post - |> Ash.Changeset.for_create(:create, %{name: "org2 post"}) - |> Ash.Changeset.set_tenant("org_" <> org2.id) - |> Ash.create!() - # Link the posts in org1 post |> Ash.Changeset.new() @@ -173,6 +166,29 @@ defmodule AshPostgres.Test.MultitenancyTest do |> Ash.Changeset.set_tenant("org_" <> org1.id) |> Ash.update!() end + end + + test "non-atomic aggregate validation prevents update with linked posts", %{org1: org1} do + # Create a post in org1 + post = + Post + |> Ash.Changeset.for_create(:create, %{name: "foo"}) + |> Ash.Changeset.set_tenant("org_" <> org1.id) + |> Ash.create!() + + # Create a linked post for the post in org1 + linked_post = + Post + |> Ash.Changeset.for_create(:create, %{name: "linked post"}) + |> Ash.Changeset.set_tenant("org_" <> org1.id) + |> Ash.create!() + + # Link the posts in org1 + post + |> Ash.Changeset.new() + |> Ash.Changeset.manage_relationship(:linked_posts, linked_post, type: :append_and_remove) + |> Ash.Changeset.set_tenant("org_" <> org1.id) + |> Ash.update!() # Test non-atomic validation assert_raise Ash.Error.Invalid, ~r/Can only update if Post has no linked posts/, fn -> @@ -183,6 +199,29 @@ defmodule AshPostgres.Test.MultitenancyTest do |> Ash.Changeset.set_tenant("org_" <> org1.id) |> Ash.update!() end + end + + test "aggregate validation prevents destroy with linked posts", %{org1: org1} do + # Create a post in org1 + post = + Post + |> Ash.Changeset.for_create(:create, %{name: "foo"}) + |> Ash.Changeset.set_tenant("org_" <> org1.id) + |> Ash.create!() + + # Create a linked post for the post in org1 + linked_post = + Post + |> Ash.Changeset.for_create(:create, %{name: "linked post"}) + |> Ash.Changeset.set_tenant("org_" <> org1.id) + |> Ash.create!() + + # Link the posts in org1 + post + |> Ash.Changeset.new() + |> Ash.Changeset.manage_relationship(:linked_posts, linked_post, type: :append_and_remove) + |> Ash.Changeset.set_tenant("org_" <> org1.id) + |> Ash.update!() # Test destroy with atomic validation assert_raise Ash.Error.Invalid, ~r/Can only delete if Post has no linked posts/, fn -> @@ -193,6 +232,29 @@ defmodule AshPostgres.Test.MultitenancyTest do |> Ash.Changeset.set_tenant("org_" <> org1.id) |> Ash.destroy!() end + end + + test "non-atomic aggregate validation prevents destroy with linked posts", %{org1: org1} do + # Create a post in org1 + post = + Post + |> Ash.Changeset.for_create(:create, %{name: "foo"}) + |> Ash.Changeset.set_tenant("org_" <> org1.id) + |> Ash.create!() + + # Create a linked post for the post in org1 + linked_post = + Post + |> Ash.Changeset.for_create(:create, %{name: "linked post"}) + |> Ash.Changeset.set_tenant("org_" <> org1.id) + |> Ash.create!() + + # Link the posts in org1 + post + |> Ash.Changeset.new() + |> Ash.Changeset.manage_relationship(:linked_posts, linked_post, type: :append_and_remove) + |> Ash.Changeset.set_tenant("org_" <> org1.id) + |> Ash.update!() # Test destroy with non-atomic validation assert_raise Ash.Error.Invalid, ~r/Can only delete if Post has no linked posts/, fn -> @@ -203,8 +265,29 @@ defmodule AshPostgres.Test.MultitenancyTest do |> Ash.Changeset.set_tenant("org_" <> org1.id) |> Ash.destroy!() end + end - # Verify that a post with no linked posts in org2 can be updated + test "post with no linked posts can be updated in another tenant", %{org1: org1, org2: org2} do + # Create a post in org1 with a linked post + post_in_org1 = + Post + |> Ash.Changeset.for_create(:create, %{name: "foo"}) + |> Ash.Changeset.set_tenant("org_" <> org1.id) + |> Ash.create!() + + linked_post = + Post + |> Ash.Changeset.for_create(:create, %{name: "linked post"}) + |> Ash.Changeset.set_tenant("org_" <> org1.id) + |> Ash.create!() + + post_in_org1 + |> Ash.Changeset.new() + |> Ash.Changeset.manage_relationship(:linked_posts, linked_post, type: :append_and_remove) + |> Ash.Changeset.set_tenant("org_" <> org1.id) + |> Ash.update!() + + # Create a post in org2 with no linked posts org2_post = Post |> Ash.Changeset.for_create(:create, %{name: "updateable"}) @@ -221,8 +304,29 @@ defmodule AshPostgres.Test.MultitenancyTest do |> Ash.update!() assert updated_post.name == "updated" + end + + test "post with no linked posts can be destroyed in another tenant", %{org1: org1, org2: org2} do + # Create a post in org1 with a linked post + post_in_org1 = + Post + |> Ash.Changeset.for_create(:create, %{name: "foo"}) + |> Ash.Changeset.set_tenant("org_" <> org1.id) + |> Ash.create!() - # Test that a post with no linked posts in org2 can be destroyed + linked_post = + Post + |> Ash.Changeset.for_create(:create, %{name: "linked post"}) + |> Ash.Changeset.set_tenant("org_" <> org1.id) + |> Ash.create!() + + post_in_org1 + |> Ash.Changeset.new() + |> Ash.Changeset.manage_relationship(:linked_posts, linked_post, type: :append_and_remove) + |> Ash.Changeset.set_tenant("org_" <> org1.id) + |> Ash.update!() + + # Create a post in org2 with no linked posts org2_post_for_destroy = Post |> Ash.Changeset.for_create(:create, %{name: "destroyable"}) @@ -236,6 +340,13 @@ defmodule AshPostgres.Test.MultitenancyTest do |> Ash.Changeset.for_destroy(:destroy_if_no_linked_posts, %{}) |> Ash.Changeset.set_tenant("org_" <> org2.id) |> Ash.destroy!() + + # Verify the post was destroyed + assert [] = + Post + |> Ash.Query.filter(id == ^org2_post_for_destroy.id) + |> Ash.Query.set_tenant("org_" <> org2.id) + |> Ash.read!() end test "loading attribute multitenant resources from context multitenant resources works" do From dae57d20da14802dc866faa2614ec3dfc727874b Mon Sep 17 00:00:00 2001 From: "Barnabas Jovanovics (aider)" Date: Wed, 23 Apr 2025 15:01:46 +0200 Subject: [PATCH 7/9] refactor: remove unnecessary `put_context(:aggregate, :exists)` calls in tests --- test/multitenancy_test.exs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/test/multitenancy_test.exs b/test/multitenancy_test.exs index c9096393..b924d987 100644 --- a/test/multitenancy_test.exs +++ b/test/multitenancy_test.exs @@ -161,7 +161,6 @@ defmodule AshPostgres.Test.MultitenancyTest do assert_raise Ash.Error.Invalid, ~r/Can only update if Post has no linked posts/, fn -> post |> Ash.Changeset.new() - |> Ash.Changeset.put_context(:aggregate, :exists) |> Ash.Changeset.for_update(:update_if_no_linked_posts, %{name: "updated"}) |> Ash.Changeset.set_tenant("org_" <> org1.id) |> Ash.update!() @@ -194,7 +193,6 @@ defmodule AshPostgres.Test.MultitenancyTest do assert_raise Ash.Error.Invalid, ~r/Can only update if Post has no linked posts/, fn -> post |> Ash.Changeset.new() - |> Ash.Changeset.put_context(:aggregate, :exists) |> Ash.Changeset.for_update(:update_if_no_linked_posts_non_atomic, %{name: "updated"}) |> Ash.Changeset.set_tenant("org_" <> org1.id) |> Ash.update!() @@ -227,7 +225,6 @@ defmodule AshPostgres.Test.MultitenancyTest do assert_raise Ash.Error.Invalid, ~r/Can only delete if Post has no linked posts/, fn -> post |> Ash.Changeset.new() - |> Ash.Changeset.put_context(:aggregate, :exists) |> Ash.Changeset.for_destroy(:destroy_if_no_linked_posts, %{}) |> Ash.Changeset.set_tenant("org_" <> org1.id) |> Ash.destroy!() @@ -260,7 +257,6 @@ defmodule AshPostgres.Test.MultitenancyTest do assert_raise Ash.Error.Invalid, ~r/Can only delete if Post has no linked posts/, fn -> post |> Ash.Changeset.new() - |> Ash.Changeset.put_context(:aggregate, :exists) |> Ash.Changeset.for_destroy(:destroy_if_no_linked_posts_non_atomic, %{}) |> Ash.Changeset.set_tenant("org_" <> org1.id) |> Ash.destroy!() @@ -298,7 +294,6 @@ defmodule AshPostgres.Test.MultitenancyTest do updated_post = org2_post |> Ash.Changeset.new() - |> Ash.Changeset.put_context(:aggregate, :exists) |> Ash.Changeset.for_update(:update_if_no_linked_posts, %{name: "updated"}) |> Ash.Changeset.set_tenant("org_" <> org2.id) |> Ash.update!() @@ -336,7 +331,6 @@ defmodule AshPostgres.Test.MultitenancyTest do # This should succeed since the post has no linked posts in org2 org2_post_for_destroy |> Ash.Changeset.new() - |> Ash.Changeset.put_context(:aggregate, :exists) |> Ash.Changeset.for_destroy(:destroy_if_no_linked_posts, %{}) |> Ash.Changeset.set_tenant("org_" <> org2.id) |> Ash.destroy!() From d273e59001114dfa4449c310cedad3a95592409d Mon Sep 17 00:00:00 2001 From: "Barnabas Jovanovics (aider)" Date: Wed, 23 Apr 2025 15:02:37 +0200 Subject: [PATCH 8/9] refactor: prefix unused changeset parameter with underscore in HasNoLinkedPosts validation --- test/support/multitenancy/resources/post.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/support/multitenancy/resources/post.ex b/test/support/multitenancy/resources/post.ex index 1c57119a..2b494223 100644 --- a/test/support/multitenancy/resources/post.ex +++ b/test/support/multitenancy/resources/post.ex @@ -2,7 +2,7 @@ defmodule HasNoLinkedPosts do @moduledoc false use Ash.Resource.Validation - def atomic(changeset, _opts, context) do + def atomic(_changeset, _opts, context) do condition = expr(exists(linked_posts, true)) [ From 6fcde136fb1efb2cd7c684c9ca142879268af8d4 Mon Sep 17 00:00:00 2001 From: Barnabas Jovanovics Date: Wed, 23 Apr 2025 15:17:09 +0200 Subject: [PATCH 9/9] chore: format code --- test/multitenancy_test.exs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/multitenancy_test.exs b/test/multitenancy_test.exs index b924d987..cca48723 100644 --- a/test/multitenancy_test.exs +++ b/test/multitenancy_test.exs @@ -336,11 +336,11 @@ defmodule AshPostgres.Test.MultitenancyTest do |> Ash.destroy!() # Verify the post was destroyed - assert [] = - Post - |> Ash.Query.filter(id == ^org2_post_for_destroy.id) - |> Ash.Query.set_tenant("org_" <> org2.id) - |> Ash.read!() + assert [] = + Post + |> Ash.Query.filter(id == ^org2_post_for_destroy.id) + |> Ash.Query.set_tenant("org_" <> org2.id) + |> Ash.read!() end test "loading attribute multitenant resources from context multitenant resources works" do