diff --git a/app/models/good_job/discrete_execution.rb b/app/models/good_job/discrete_execution.rb index adc54825..e27483df 100644 --- a/app/models/good_job/discrete_execution.rb +++ b/app/models/good_job/discrete_execution.rb @@ -14,6 +14,9 @@ class DiscreteExecution < BaseRecord alias_attribute :performed_at, :created_at + # TODO: Remove when support for Rails 6.1 is dropped + attribute :duration, :interval + def number serialized_params.fetch('executions', 0) + 1 end diff --git a/spec/app/models/good_job/job_spec.rb b/spec/app/models/good_job/job_spec.rb index 0067eee1..63afcabe 100644 --- a/spec/app/models/good_job/job_spec.rb +++ b/spec/app/models/good_job/job_spec.rb @@ -972,7 +972,7 @@ def job_params created_at: within(0.001).of(good_job.performed_at), scheduled_at: within(0.001).of(good_job.created_at), finished_at: within(1.second).of(Time.current), - duration: be_present, + duration: be_a(ActiveSupport::Duration), error: nil, serialized_params: good_job.serialized_params ) @@ -1011,7 +1011,7 @@ def job_params created_at: within(1.second).of(Time.current), scheduled_at: within(1.second).of(Time.current), finished_at: within(1.second).of(Time.current), - duration: be_present + duration: be_a(ActiveSupport::Duration) ) end end @@ -1036,7 +1036,7 @@ def job_params expect(good_job.discrete_executions.first).to have_attributes( performed_at: within(1.second).of(Time.current), finished_at: within(1.second).of(Time.current), - duration: be_present + duration: be_a(ActiveSupport::Duration) ) end end