Class: ActiveJob::QueueAdapters::TestAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/active_job/queue_adapters/test_adapter.rb

Overview

Test adapter for Active Job

The test adapter should be used only in testing. Along with ActiveJob::TestCase and ActiveJob::TestHelper it makes a great tool to test your Rails application.

To use the test adapter set queue_adapter config to :test.

Rails.application.config.active_job.queue_adapter = :test

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#atObject

Returns the value of attribute at.



15
16
17
# File 'lib/active_job/queue_adapters/test_adapter.rb', line 15

def at
  @at
end

#enqueued_jobsObject

Provides a store of all the enqueued jobs with the TestAdapter so you can check them.



19
20
21
# File 'lib/active_job/queue_adapters/test_adapter.rb', line 19

def enqueued_jobs
  @enqueued_jobs ||= []
end

#filterObject

Returns the value of attribute filter.



15
16
17
# File 'lib/active_job/queue_adapters/test_adapter.rb', line 15

def filter
  @filter
end

#perform_enqueued_at_jobsObject

Returns the value of attribute perform_enqueued_at_jobs.



15
16
17
# File 'lib/active_job/queue_adapters/test_adapter.rb', line 15

def perform_enqueued_at_jobs
  @perform_enqueued_at_jobs
end

#perform_enqueued_jobsObject

Returns the value of attribute perform_enqueued_jobs.



15
16
17
# File 'lib/active_job/queue_adapters/test_adapter.rb', line 15

def perform_enqueued_jobs
  @perform_enqueued_jobs
end

#performed_jobsObject

Provides a store of all the performed jobs with the TestAdapter so you can check them.



24
25
26
# File 'lib/active_job/queue_adapters/test_adapter.rb', line 24

def performed_jobs
  @performed_jobs ||= []
end

#queueObject

Returns the value of attribute queue.



15
16
17
# File 'lib/active_job/queue_adapters/test_adapter.rb', line 15

def queue
  @queue
end

#rejectObject

Returns the value of attribute reject.



15
16
17
# File 'lib/active_job/queue_adapters/test_adapter.rb', line 15

def reject
  @reject
end

Instance Method Details

#enqueue(job) ⇒ Object

:nodoc:



28
29
30
31
# File 'lib/active_job/queue_adapters/test_adapter.rb', line 28

def enqueue(job) # :nodoc:
  job_data = job_to_hash(job)
  perform_or_enqueue(perform_enqueued_jobs && !filtered?(job), job, job_data)
end

#enqueue_at(job, timestamp) ⇒ Object

:nodoc:



33
34
35
36
# File 'lib/active_job/queue_adapters/test_adapter.rb', line 33

def enqueue_at(job, timestamp) # :nodoc:
  job_data = job_to_hash(job, at: timestamp)
  perform_or_enqueue(perform_enqueued_at_jobs && !filtered?(job), job, job_data)
end