mirror of
https://github.com/ash-project/ash.git
synced 2024-09-19 13:03:02 +12:00
chore: run proper callback and test that we call the loading callback
This commit is contained in:
parent
51f57b6390
commit
48507eac13
3 changed files with 9 additions and 1 deletions
|
@ -360,7 +360,7 @@ defmodule Ash.Actions.Read do
|
|||
case query.action.manual do
|
||||
{module, opts} ->
|
||||
if module.has_load_relationships?() do
|
||||
module.load_relationships(query, data, opts, lazy?)
|
||||
module.load_relationships(query, data, opts, context, lazy?)
|
||||
else
|
||||
Ash.Actions.Read.Relationships.load(
|
||||
data,
|
||||
|
|
|
@ -35,7 +35,12 @@ defmodule Ash.Resource.ManualRead do
|
|||
defmacro __using__(_) do
|
||||
quote do
|
||||
@behaviour Ash.Resource.ManualRead
|
||||
@before_compile Ash.Resource.ManualRead
|
||||
end
|
||||
end
|
||||
|
||||
defmacro __before_compile__(_) do
|
||||
quote do
|
||||
if Module.defines?(__MODULE__, {:load_relationships, 5}, :def) do
|
||||
def has_load_relationships?, do: true
|
||||
else
|
||||
|
|
|
@ -8,6 +8,7 @@ defmodule Ash.Test.Actions.ManualReadTest do
|
|||
use Ash.Resource.ManualRead
|
||||
|
||||
def load_relationships(_, data, _, _, _) do
|
||||
send(self(), :loading_relationships)
|
||||
{:ok, data}
|
||||
end
|
||||
|
||||
|
@ -109,6 +110,8 @@ defmodule Ash.Test.Actions.ManualReadTest do
|
|||
Author
|
||||
|> Ash.Query.for_read(:all)
|
||||
|> Ash.read!()
|
||||
|
||||
assert_received :loading_relationships
|
||||
end
|
||||
|
||||
test "Ash.Query.apply_to/2 can be used" do
|
||||
|
|
Loading…
Reference in a new issue