diff --git a/lib/oban/config.ex b/lib/oban/config.ex index c97596f9..2bff48bc 100644 --- a/lib/oban/config.ex +++ b/lib/oban/config.ex @@ -154,7 +154,7 @@ defmodule Oban.Config do def get_engine(%__MODULE__{engine: engine, testing: :disabled}), do: engine def get_engine(%__MODULE__{engine: engine, testing: testing}) do - pids = [self() | Process.get(:"$ancestors", [])] + pids = [self() | Process.get(:"$callers", [])] if Enum.any?(pids, &inline_testing?(&1, testing)) do Oban.Engines.Inline @@ -163,14 +163,12 @@ defmodule Oban.Config do end end - defp inline_testing?(pid, default) when is_pid(pid) do + defp inline_testing?(pid, default) do {:dictionary, dictionary} = Process.info(pid, :dictionary) Keyword.get(dictionary, :oban_testing, default) == :inline end - defp inline_testing?(_pid, _default), do: false - @doc false @spec node_name(%{optional(binary()) => binary()}) :: binary() def node_name(env \\ System.get_env()) do diff --git a/test/oban/testing_test.exs b/test/oban/testing_test.exs index 30d4b6b6..6a53f78a 100644 --- a/test/oban/testing_test.exs +++ b/test/oban/testing_test.exs @@ -405,8 +405,6 @@ defmodule Oban.TestingTest do Testing.with_testing_mode(:inline, fn -> fun = fn -> - Process.put(:"$ancestors", [Some.Endpoint | Process.get(:"$ancestors")]) - Oban.insert!(name, Worker.new(%{ref: 1, action: "OK"})) assert_received {:ok, 1}