@@ -31,6 +31,7 @@ def assert_finished_in_order(*batches)
3131 SolidQueue ::BatchRecord . destroy_all
3232
3333 ApplicationJob . enqueue_after_transaction_commit = false if defined? ( ApplicationJob . enqueue_after_transaction_commit )
34+ SolidQueue . preserve_finished_jobs = true
3435 end
3536
3637 class BatchOnSuccessJob < ApplicationJob
@@ -231,13 +232,24 @@ def perform
231232 assert_finished_in_order ( batch2 , batch1 )
232233 end
233234
234- # TODO: spec for each callback type firing properly
235-
236235 test "preserve_finished_jobs = false" do
237- # SolidQueue.preserve_finished_jobs = false
238- # batch1 = SolidQueue::Batch.enqueue do
239- # AddToBufferJob.perform_later "hey"
240- # end
236+ SolidQueue . preserve_finished_jobs = false
237+ batch1 = SolidQueue ::Batch . enqueue do
238+ AddToBufferJob . perform_later "hey"
239+ end
240+
241+ assert_equal false , batch1 . reload . finished?
242+ assert_equal 1 , SolidQueue ::Job . count
243+ assert_equal 0 , SolidQueue ::Job . finished . count
244+
245+ @dispatcher . start
246+ @worker . start
247+
248+ wait_for_job_batches_to_finish_for ( 2 . seconds )
249+ wait_for_jobs_to_finish_for ( 2 . seconds )
250+
251+ assert_equal true , batch1 . reload . finished?
252+ assert_equal 0 , SolidQueue ::Job . count
241253 end
242254
243255 test "batch interface" do
0 commit comments