Skip to content

Commit 8f69188

Browse files
committed
guard job queue for no request_id
- only add a request_id to the job if there is a request_id specs tend not to stub out request_id
1 parent 2211451 commit 8f69188

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

app/jobs/application_job.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ class ApplicationJob < ActiveJob::Base
22
attr_reader :request_id
33

44
before_enqueue do
5-
arguments << { request_id: Current.request_id }
5+
arguments << { request_id: Current.request_id } if Current.request_id
66
end
77

88
around_perform do |job, block|
9-
@request_id = job.arguments.pop[:request_id] || ''
9+
if job.arguments.last.is_a?(Hash) && job.arguments.last.key?(:request_id)
10+
@request_id = job.arguments.pop[:request_id]
11+
end
1012
block.call
1113
end
1214

0 commit comments

Comments
 (0)