Skip to content

Commit

Permalink
Merge pull request #47556 from codez/failsafe_delayed_job_name
Browse files Browse the repository at this point in the history
Make delayed job display_name failsafe
  • Loading branch information
rafaelfranca committed Mar 3, 2023
2 parents 18e53fb + 3d3ed6e commit dd7ecb0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def perform
private
def log_arguments?
job_data["job_class"].constantize.log_arguments?
rescue NameError
false
end
end
end
Expand Down
13 changes: 13 additions & 0 deletions activejob/test/cases/delayed_job_adapter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,17 @@ class DelayedJobAdapterTest < ActiveSupport::TestCase
assert_equal "HelloJob [#{job_id}] from DelayedJob(default) with arguments: #{arguments}",
job_wrapper.display_name
end

test "shows name for invalid job class" do
job_id = SecureRandom.uuid

job_wrapper = ActiveJob::QueueAdapters::DelayedJobAdapter::JobWrapper.new(
"job_class" => "NotExistingJob",
"queue_name" => "default",
"job_id" => job_id,
"arguments" => { "some" => { "job" => "arguments" } }
)

assert_equal "NotExistingJob [#{job_id}] from DelayedJob(default)", job_wrapper.display_name
end
end

0 comments on commit dd7ecb0

Please sign in to comment.