aboutsummaryrefslogtreecommitdiffstats
path: root/activejob/test/support/integration/adapters/delayed_job.rb
blob: fc9bae47fadf840ed62837e400577307882f38d9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true

require "delayed_job"
require "delayed_job_active_record"

module DelayedJobJobsManager
  def setup
    ActiveJob::Base.queue_adapter = :delayed_job
  end
  def clear_jobs
    Delayed::Job.delete_all
  end

  def start_workers
    @worker = Delayed::Worker.new(quiet: true, sleep_delay: 0.5, queues: %w(integration_tests))
    @thread = Thread.new { @worker.start }
  end

  def stop_workers
    @worker.stop
    @thread.join
  end
end