aboutsummaryrefslogtreecommitdiffstats
path: root/activejob/lib/active_job/queue_adapters/test_adapter.rb
diff options
context:
space:
mode:
authorAbdelkader Boudih <terminale@gmail.com>2014-08-29 20:11:17 +0000
committerAbdelkader Boudih <terminale@gmail.com>2014-09-02 07:50:16 +0000
commitfccf3d0b6304a7b8dacad05b63f24cdf41e652df (patch)
tree50450c272fe7264af1f1f12c1ad03225298b20e6 /activejob/lib/active_job/queue_adapters/test_adapter.rb
parenteb4245dd17ba66c0551f3d4ed841b471bcf01b91 (diff)
downloadrails-fccf3d0b6304a7b8dacad05b63f24cdf41e652df.tar.gz
rails-fccf3d0b6304a7b8dacad05b63f24cdf41e652df.tar.bz2
rails-fccf3d0b6304a7b8dacad05b63f24cdf41e652df.zip
[ActiveJob] TestCase
Diffstat (limited to 'activejob/lib/active_job/queue_adapters/test_adapter.rb')
-rw-r--r--activejob/lib/active_job/queue_adapters/test_adapter.rb118
1 files changed, 58 insertions, 60 deletions
diff --git a/activejob/lib/active_job/queue_adapters/test_adapter.rb b/activejob/lib/active_job/queue_adapters/test_adapter.rb
index f7c4d19638..2cab9e946d 100644
--- a/activejob/lib/active_job/queue_adapters/test_adapter.rb
+++ b/activejob/lib/active_job/queue_adapters/test_adapter.rb
@@ -1,76 +1,74 @@
module ActiveJob
module QueueAdapters
class TestAdapter
- mattr_accessor(:perform_enqueued_jobs) { false }
- mattr_accessor(:perform_enqueued_at_jobs) { false }
+ attr_accessor(:perform_enqueued_jobs) { false }
+ attr_accessor(:perform_enqueued_at_jobs) { false }
- class << self
- # Provides a store of all the enqueued jobs with the TestAdapter so you can check them.
- def enqueued_jobs
- @@enqueued_jobs ||= []
- end
+ # Provides a store of all the enqueued jobs with the TestAdapter so you can check them.
+ def enqueued_jobs
+ @@enqueued_jobs ||= []
+ end
- # Allows you to over write the default enqueued jobs store from an array to some
- # other object. If you just want to clear the store,
- # call ActiveJob::QueueAdapters::TestAdapter.enqueued_jobs.clear.
- #
- # If you place another object here, please make sure it responds to:
- #
- # * << (message)
- # * clear
- # * length
- # * size
- # * and other common Array methods
- def enqueued_jobs=(val)
- @@enqueued_jobs = val
- end
+ # Allows you to over write the default enqueued jobs store from an array to some
+ # other object. If you just want to clear the store,
+ # call ActiveJob::QueueAdapters::TestAdapter.enqueued_jobs.clear.
+ #
+ # If you place another object here, please make sure it responds to:
+ #
+ # * << (message)
+ # * clear
+ # * length
+ # * size
+ # * and other common Array methods
+ def enqueued_jobs=(val)
+ @@enqueued_jobs = val
+ end
- # Provides a store of all the performed jobs with the TestAdapter so you can check them.
- def performed_jobs
- @@performed_jobs ||= []
- end
+ # Provides a store of all the performed jobs with the TestAdapter so you can check them.
+ def performed_jobs
+ @@performed_jobs ||= []
+ end
- # Allows you to over write the default performed jobs store from an array to some
- # other object. If you just want to clear the store,
- # call ActiveJob::QueueAdapters::TestAdapter.performed_jobs.clear.
- #
- # If you place another object here, please make sure it responds to:
- #
- # * << (message)
- # * clear
- # * length
- # * size
- # * and other common Array methods
- def performed_jobs=(val)
- @@performed_jobs = val
- end
+ # Allows you to over write the default performed jobs store from an array to some
+ # other object. If you just want to clear the store,
+ # call ActiveJob::QueueAdapters::TestAdapter.performed_jobs.clear.
+ #
+ # If you place another object here, please make sure it responds to:
+ #
+ # * << (message)
+ # * clear
+ # * length
+ # * size
+ # * and other common Array methods
+ def performed_jobs=(val)
+ @@performed_jobs = val
+ end
- def enqueue(job, *args)
- if perform_enqueued_jobs?
- performed_jobs << {job: job, args: args, queue: job.queue_name}
- job.new.execute(*args)
- else
- enqueued_jobs << {job: job, args: args, queue: job.queue_name}
- end
+ def enqueue(job, *args)
+ if perform_enqueued_jobs?
+ performed_jobs << {job: job, args: args, queue: job.queue_name}
+ job.new.execute(*args)
+ else
+ enqueued_jobs << {job: job, args: args, queue: job.queue_name}
end
+ end
- def enqueue_at(job, timestamp, *args)
- if perform_enqueued_at_jobs?
- performed_jobs << {job: job, args: args, queue: job.queue_name, run_at: timestamp}
- job.new.execute(*args)
- else
- enqueued_jobs << {job: job, args: args, queue: job.queue_name, run_at: timestamp}
- end
+ def enqueue_at(job, timestamp, *args)
+ if perform_enqueued_at_jobs?
+ performed_jobs << {job: job, args: args, queue: job.queue_name, run_at: timestamp}
+ job.new.execute(*args)
+ else
+ enqueued_jobs << {job: job, args: args, queue: job.queue_name, run_at: timestamp}
end
+ end
- private
- def perform_enqueued_jobs?
- perform_enqueued_jobs
- end
+ private
+ def perform_enqueued_jobs?
+ perform_enqueued_jobs
+ end
- def perform_enqueued_at_jobs?
- perform_enqueued_at_jobs
- end
+ def perform_enqueued_at_jobs?
+ perform_enqueued_at_jobs
end
end
end