Class: ActiveJob::QueueAdapters::TestAdapter

Inherits:
Object
  • Object
show all
Defined in:
activejob/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

#enqueued_jobsObject

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


17
18
19
# File 'activejob/lib/active_job/queue_adapters/test_adapter.rb', line 17

def enqueued_jobs
  @enqueued_jobs ||= []
end

#filterObject

Returns the value of attribute filter


13
14
15
# File 'activejob/lib/active_job/queue_adapters/test_adapter.rb', line 13

def filter
  @filter
end

#perform_enqueued_at_jobsObject

Returns the value of attribute perform_enqueued_at_jobs


13
14
15
# File 'activejob/lib/active_job/queue_adapters/test_adapter.rb', line 13

def perform_enqueued_at_jobs
  @perform_enqueued_at_jobs
end

#perform_enqueued_jobsObject

Returns the value of attribute perform_enqueued_jobs


13
14
15
# File 'activejob/lib/active_job/queue_adapters/test_adapter.rb', line 13

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.


22
23
24
# File 'activejob/lib/active_job/queue_adapters/test_adapter.rb', line 22

def performed_jobs
  @performed_jobs ||= []
end

Instance Method Details

#enqueue(job) ⇒ Object

:nodoc:


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

def enqueue(job) #:nodoc:
  return if filtered?(job)

  job_data = job_to_hash(job)
  enqueue_or_perform(perform_enqueued_jobs, job, job_data)
end

#enqueue_at(job, timestamp) ⇒ Object

:nodoc:


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

def enqueue_at(job, timestamp) #:nodoc:
  return if filtered?(job)

  job_data = job_to_hash(job, at: timestamp)
  enqueue_or_perform(perform_enqueued_at_jobs, job, job_data)
end