@@ -30,6 +30,11 @@ def perform(arg, kwarg:)
3030 expect ( queue ) . to have_received ( :enqueue ) . with ( context , delay : 10 , delay_until : nil )
3131 end
3232
33+ it "returns nil" do
34+ result = task_class . enqueue ( "value" , kwarg : "value2" , delay : 10 )
35+ expect ( result ) . to be_nil
36+ end
37+
3338 it "correctly passes delay_until" do
3439 time = Time . now
3540 task_class . enqueue ( delay_until : time )
@@ -75,7 +80,8 @@ def perform(arg, kwarg:)
7580
7681 context "when task succeeds" do
7782 before do
78- allow ( Rage ::Deferred ::Context ) . to receive ( :get_request_id ) . with ( context ) . and_return ( "request-id" )
83+ allow ( Rage ::Deferred ::Context ) . to receive ( :get_log_tags ) . with ( context ) . and_return ( [ "request-id" ] )
84+ allow ( Rage ::Deferred ::Context ) . to receive ( :get_log_context ) . with ( context ) . and_return ( { } )
7985 allow ( task ) . to receive ( :perform )
8086 end
8187
@@ -87,7 +93,7 @@ def perform(arg, kwarg:)
8793 it "logs with context and tag" do
8894 task . __perform ( context )
8995 expect ( logger ) . to have_received ( :with_context ) . with ( { task : "MyTask" , attempt : 2 } )
90- expect ( logger ) . to have_received ( :tagged ) . with ( "request-id" )
96+ expect ( Thread . current [ :rage_logger ] ) . to eq ( { tags : [ "request-id" ] , context : { } } )
9197 end
9298
9399 it "returns true" do
@@ -102,7 +108,8 @@ def perform(arg, kwarg:)
102108
103109 context "when request_id is not present" do
104110 before do
105- allow ( Rage ::Deferred ::Context ) . to receive ( :get_request_id ) . with ( context ) . and_return ( nil )
111+ allow ( Rage ::Deferred ::Context ) . to receive ( :get_log_tags ) . with ( context ) . and_return ( nil )
112+ allow ( Rage ::Deferred ::Context ) . to receive ( :get_log_context ) . with ( context ) . and_return ( { } )
106113 allow ( task ) . to receive ( :perform )
107114 end
108115
@@ -116,7 +123,8 @@ def perform(arg, kwarg:)
116123 let ( :error ) { StandardError . new ( "Something went wrong" ) }
117124
118125 before do
119- allow ( Rage ::Deferred ::Context ) . to receive ( :get_request_id ) . with ( context ) . and_return ( nil )
126+ allow ( Rage ::Deferred ::Context ) . to receive ( :get_log_tags ) . with ( context ) . and_return ( nil )
127+ allow ( Rage ::Deferred ::Context ) . to receive ( :get_log_context ) . with ( context ) . and_return ( { } )
120128 allow ( task ) . to receive ( :perform ) . and_raise ( error )
121129 allow ( error ) . to receive ( :backtrace ) . and_return ( [ "line 1" , "line 2" ] )
122130 end
0 commit comments