From 0f614aea15ae1def52120dbbba5ec5dd0077f6ae Mon Sep 17 00:00:00 2001 From: Barnabas Jovanovics Date: Wed, 14 Feb 2024 14:17:05 +0100 Subject: [PATCH] add another test case with 2 relationships --- test/filter_field_policy_test.exs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/test/filter_field_policy_test.exs b/test/filter_field_policy_test.exs index 451b4ed..4275d68 100644 --- a/test/filter_field_policy_test.exs +++ b/test/filter_field_policy_test.exs @@ -1,7 +1,7 @@ defmodule FilterFieldPolicyTest do use AshPostgres.RepoCase, async: false - alias AshPostgres.Test.{Api, Post, Organization} + alias AshPostgres.Test.{Api, Post, Organization, User} require Ash.Query @@ -36,6 +36,10 @@ defmodule FilterFieldPolicyTest do |> Ash.Changeset.for_create(:create, %{name: "test_org"}) |> Api.create!() + User + |> Ash.Changeset.for_create(:create, %{organization_id: organization.id, name: "foo bar"}) + |> Api.create!() + Post |> Ash.Changeset.for_create(:create, %{organization_id: organization.id}) |> Api.create!() @@ -46,6 +50,14 @@ defmodule FilterFieldPolicyTest do Post |> Ash.Query.do_filter(filter) |> Ash.Query.for_read(:allow_any) - |> Api.read!(actor: %{id: "%test"}) + |> Api.read!(actor: %{id: "test"}) + + filter = Ash.Filter.parse_input!(Post, %{organization: %{users: %{name: %{ilike: "%bar"}}}}) + + assert [_] = + Post + |> Ash.Query.do_filter(filter) + |> Ash.Query.for_read(:allow_any) + |> Api.read!(actor: %{id: "test"}) end end