Module: Sidekiq::TestingClient

Defined in:
lib/sidekiq/testing.rb

Instance Method Summary collapse

Instance Method Details

#raw_push(payloads) ⇒ Object


76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/sidekiq/testing.rb', line 76

def raw_push(payloads)
  if Sidekiq::Testing.fake?
    payloads.each do |job|
      job = Sidekiq.load_json(Sidekiq.dump_json(job))
      job.merge!('enqueued_at' => Time.now.to_f) unless job['at']
      Queues.push(job['queue'], job['class'], job)
    end
    true
  elsif Sidekiq::Testing.inline?
    payloads.each do |job|
      klass = Sidekiq::Testing.constantize(job['class'])
      job['id'] ||= SecureRandom.hex(12)
      job_hash = Sidekiq.load_json(Sidekiq.dump_json(job))
      klass.process_job(job_hash)
    end
    true
  else
    super
  end
end