Module: Delayed::Testing

Defined in:
lib/delayed/testing.rb

Class Method Summary collapse

Class Method Details

.clear_all!Object


24
25
26
27
28
29
30
31
32
# File 'lib/delayed/testing.rb', line 24

def self.clear_all!
  case Delayed::Job.name
  when /Redis/
    Delayed::Job.redis.flushdb
  when /ActiveRecord/
    Delayed::Job.delete_all
    Delayed::Job::Failed.delete_all
  end
end

.drainObject


9
10
11
12
13
14
15
16
17
# File 'lib/delayed/testing.rb', line 9

def self.drain
  while job = Delayed::Job.get_and_lock_next_available(
      'spec run_jobs',
      Delayed::Settings.queue,
      0,
      Delayed::MAX_PRIORITY)
    run_job(job)
  end
end

.run_job(job) ⇒ Object


5
6
7
# File 'lib/delayed/testing.rb', line 5

def self.run_job(job)
  Delayed::Worker.new.perform(job)
end

.track_createdObject


19
20
21
22
# File 'lib/delayed/testing.rb', line 19

def self.track_created
  job_tracking = JobTracking.track { yield }
  job_tracking.created
end