@@ -8,6 +8,12 @@ class SolidQueue::JobBatchTest < ActiveSupport::TestCase
88 SolidQueue ::JobBatch . destroy_all
99 end
1010
11+ class BatchWithArgumentsJob < ApplicationJob
12+ def perform ( batch , arg1 , arg2 )
13+ Rails . logger . info "Hi #{ batch . id } , #{ arg1 } , #{ arg2 } !"
14+ end
15+ end
16+
1117 class NiceJob < ApplicationJob
1218 retry_on Exception , wait : 1 . second
1319
@@ -18,14 +24,14 @@ def perform(arg)
1824
1925 test "batch will be completed on success" do
2026 batch = SolidQueue ::JobBatch . enqueue ( on_finish : BatchCompletionJob ) { }
21- assert_equal "success" , batch . completion_type
22- assert_equal BatchCompletionJob . name , batch . job_class
27+ assert_not_nil batch . on_finish_active_job
28+ assert_equal BatchCompletionJob . name , batch . on_finish_active_job [ " job_class" ]
2329 end
2430
2531 test "batch will be completed on finish" do
2632 batch = SolidQueue ::JobBatch . enqueue ( on_success : BatchCompletionJob ) { }
27- assert_equal "success" , batch . completion_type
28- assert_equal BatchCompletionJob . name , batch . job_class
33+ assert_not_nil batch . on_success_active_job
34+ assert_equal BatchCompletionJob . name , batch . on_success_active_job [ " job_class" ]
2935 end
3036
3137 test "sets the batch_id on jobs created inside of the enqueue block" do
@@ -45,4 +51,16 @@ def perform(arg)
4551 end
4652 assert_nil SolidQueue ::JobBatch . current_batch_id
4753 end
54+
55+ test "allow arguments and options for callbacks" do
56+ SolidQueue ::JobBatch . enqueue (
57+ on_finish : BatchWithArgumentsJob . new ( 1 , 2 ) . set ( queue : :batch ) ,
58+ ) do
59+ NiceJob . perform_later ( "world" )
60+ end
61+
62+ assert_not_nil SolidQueue ::JobBatch . last . on_finish_active_job [ "arguments" ]
63+ assert_equal SolidQueue ::JobBatch . last . on_finish_active_job [ "arguments" ] , [ 1 , 2 ]
64+ assert_equal SolidQueue ::JobBatch . last . on_finish_active_job [ "queue_name" ] , "batch"
65+ end
4866end
0 commit comments