diff --git a/lib/quantum/normalizer.ex b/lib/quantum/normalizer.ex index 482519e..a2e2cc3 100644 --- a/lib/quantum/normalizer.ex +++ b/lib/quantum/normalizer.ex @@ -51,6 +51,14 @@ defmodule Quantum.Normalizer do normalize_options(base, %{schedule: schedule, task: task}) end + def normalize(%Job{} = base, {schedule, task, opts}) when is_list(opts) do + opts = + Enum.into(opts, %{}) + |> Map.merge(%{schedule: schedule, task: task}) + + normalize_options(base, opts) + end + def normalize(%Job{} = _base, %Job{} = job) do job end diff --git a/test/quantum/normalizer_test.exs b/test/quantum/normalizer_test.exs index d331304..3b0e140 100644 --- a/test/quantum/normalizer_test.exs +++ b/test/quantum/normalizer_test.exs @@ -143,10 +143,13 @@ defmodule Quantum.NormalizerTest do test "unnamed job as tuple with arguments" do schedule = ~e[* * * * *] task = {MyModule, :my_method, [1, 2, 3]} + opts = [state: :inactive] - job = {"* * * * *", task} + job = {"* * * * *", task, opts} + + assert %{schedule: ^schedule, task: ^task, name: name, state: :inactive} = + normalize(Scheduler.new_job(), job) - assert %{schedule: ^schedule, task: ^task, name: name} = normalize(Scheduler.new_job(), job) assert is_reference(name) end