mirror of
https://github.com/ash-project/ash_postgres.git
synced 2024-09-19 21:13:19 +12:00
add another test case with 2 relationships
This commit is contained in:
parent
a3d0fa3ffd
commit
0f614aea15
1 changed files with 14 additions and 2 deletions
|
@ -1,7 +1,7 @@
|
||||||
defmodule FilterFieldPolicyTest do
|
defmodule FilterFieldPolicyTest do
|
||||||
use AshPostgres.RepoCase, async: false
|
use AshPostgres.RepoCase, async: false
|
||||||
|
|
||||||
alias AshPostgres.Test.{Api, Post, Organization}
|
alias AshPostgres.Test.{Api, Post, Organization, User}
|
||||||
|
|
||||||
require Ash.Query
|
require Ash.Query
|
||||||
|
|
||||||
|
@ -36,6 +36,10 @@ defmodule FilterFieldPolicyTest do
|
||||||
|> Ash.Changeset.for_create(:create, %{name: "test_org"})
|
|> Ash.Changeset.for_create(:create, %{name: "test_org"})
|
||||||
|> Api.create!()
|
|> Api.create!()
|
||||||
|
|
||||||
|
User
|
||||||
|
|> Ash.Changeset.for_create(:create, %{organization_id: organization.id, name: "foo bar"})
|
||||||
|
|> Api.create!()
|
||||||
|
|
||||||
Post
|
Post
|
||||||
|> Ash.Changeset.for_create(:create, %{organization_id: organization.id})
|
|> Ash.Changeset.for_create(:create, %{organization_id: organization.id})
|
||||||
|> Api.create!()
|
|> Api.create!()
|
||||||
|
@ -46,6 +50,14 @@ defmodule FilterFieldPolicyTest do
|
||||||
Post
|
Post
|
||||||
|> Ash.Query.do_filter(filter)
|
|> Ash.Query.do_filter(filter)
|
||||||
|> Ash.Query.for_read(:allow_any)
|
|> 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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue