diff --git a/spec/integration/scheduler_spec.rb b/spec/integration/scheduler_spec.rb index 59f55b2d2..1e54ec253 100644 --- a/spec/integration/scheduler_spec.rb +++ b/spec/integration/scheduler_spec.rb @@ -1,6 +1,8 @@ require 'rails_helper' RSpec.describe 'Schedule Integration' do + let(:adapter) { GoodJob::Adapter.new(execution_mode: :external) } + before do ActiveJob::Base.queue_adapter = adapter @@ -38,15 +40,15 @@ def perform(*args, **kwargs) end), transfer_nested_constants: true end - let(:adapter) { GoodJob::Adapter.new } - context 'when there are a large number of jobs' do let(:number_of_jobs) { 500 } let(:max_threads) { 5 } let!(:good_jobs) do - number_of_jobs.times do |i| - ExampleJob.perform_later(i) + GoodJob::Job.transaction do + number_of_jobs.times do |i| + ExampleJob.perform_later(i) + end end end @@ -77,8 +79,10 @@ def perform(*args, **kwargs) let(:number_of_jobs) { 50 } let!(:good_jobs) do - number_of_jobs.times do |i| - ExampleJob.perform_later(i) + GoodJob::Job.transaction do + number_of_jobs.times do |i| + ExampleJob.perform_later(i) + end end end @@ -117,6 +121,7 @@ def perform(*args, **kwargs) it 'warms up and schedules them in a cache' do performer = GoodJob::JobPerformer.new('*') scheduler = GoodJob::Scheduler.new(performer, max_threads: 5, max_cache: 5) + scheduler.warm_cache sleep_until(max: 5, increments_of: 0.5) { GoodJob::Job.count == 0 } scheduler.shutdown end