Skip to content

Commit

Permalink
Deserialize ActiveJob arguments when manually retrying a job (#513)
Browse files Browse the repository at this point in the history
  • Loading branch information
bensheldon authored Feb 7, 2022
1 parent 82beb69 commit 2533ffa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lib/good_job/execution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,9 @@ def executable?
end

def active_job
ActiveJob::Base.deserialize(active_job_data)
ActiveJob::Base.deserialize(active_job_data).tap do |aj|
aj.send(:deserialize_arguments_if_needed)
end
end

private
Expand Down
7 changes: 5 additions & 2 deletions spec/lib/good_job/active_job_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
ActiveJob::Base.queue_adapter = GoodJob::Adapter.new(execution_mode: :external)

stub_const 'TestJob', (Class.new(ActiveJob::Base) do
def perform
def perform(feline = nil, canine: nil)
end
end)
stub_const 'TestJob::Error', Class.new(StandardError)
Expand All @@ -28,6 +28,7 @@ def perform
'executions' => 0,
'queue_name' => 'mice',
'priority' => 10,
'arguments' => ['cat', { 'canine' => 'dog' }],
}
)
end
Expand All @@ -45,6 +46,7 @@ def perform
'exception_executions' => { 'TestJob::Error' => 1 },
'queue_name' => 'mice',
'priority' => 10,
'arguments' => ['cat', { 'canine' => 'dog' }],
}
).tap do |execution|
tail_execution.update!(
Expand Down Expand Up @@ -139,7 +141,8 @@ def perform
expect(new_head_execution.serialized_params).to include(
"executions" => 2,
"queue_name" => "mice",
"priority" => 10
"priority" => 10,
"arguments" => ['cat', hash_including('canine' => 'dog')]
)

original_head_execution.reload
Expand Down

0 comments on commit 2533ffa

Please sign in to comment.