@@ -22,19 +22,15 @@ def perform(*args); end
2222 it 'enqueues the job with the request_id' do
2323 expect do
2424 TestJob . perform_later ( 'some_arg' )
25- end . to have_enqueued_job ( TestJob ) . with ( 'some_arg' , { request_id : request_id } )
26- end
27-
28- it 'sets @request_id and removes it from the arguments' do
29- job = TestJob . new ( 'some_arg' , { request_id : request_id } )
30- perform_enqueued_jobs { job . perform_now }
25+ end . to have_enqueued_job ( TestJob )
3126
32- expect ( job . instance_variable_get ( :@request_id ) ) . to eq ( request_id )
33- expect ( job . arguments ) . to eq ( [ 'some_arg' ] )
27+ enqueued_job = ActiveJob ::Base . queue_adapter . enqueued_jobs . last
28+ expect ( enqueued_job [ :args ] ) . to eq ( [ 'some_arg' ] )
29+ expect ( enqueued_job [ 'request_id' ] ) . to eq ( request_id )
3430 end
3531
3632 it 'logs the activejob_id and request_id' do
37- job = TestJob . new ( 'some_arg' , { request_id : request_id } )
33+ job = TestJob . new ( 'some_arg' )
3834 allow ( job . logger ) . to receive ( :with_fields= )
3935
4036 perform_enqueued_jobs { job . perform_now }
@@ -50,14 +46,17 @@ def perform(*args); end
5046 expect do
5147 TestJob . perform_later ( 'some_arg' )
5248 end . to have_enqueued_job ( TestJob ) . with ( 'some_arg' )
49+
50+ enqueued_job = ActiveJob ::Base . queue_adapter . enqueued_jobs . last
51+ expect ( enqueued_job [ 'request_id' ] ) . to be_nil
5352 end
5453
55- it 'does not set @ request_id if not provided' do
54+ it 'does not set request_id if not provided' do
5655 job = TestJob . new ( 'some_arg' )
5756 perform_enqueued_jobs { job . perform_now }
5857
59- expect ( job . instance_variable_get ( :@request_id ) ) . to be_nil
6058 expect ( job . arguments ) . to eq ( [ 'some_arg' ] )
59+ expect ( job . request_id ) . to be_nil
6160 end
6261
6362 it 'logs the activejob_id without a request_id' do
0 commit comments