aboutsummaryrefslogtreecommitdiffstats
path: root/activejob/test/jobs
diff options
context:
space:
mode:
authorRosa Gutierrez <rosa.ge@gmail.com>2019-01-07 14:36:56 +0100
committerRosa Gutierrez <rosa.ge@gmail.com>2019-01-08 12:07:38 +0100
commit154057b4f7d8bcf37637ec7185ede3c4d0cd6583 (patch)
treed02fc14c2599acec74c6c15ce28b5e3cf001ebee /activejob/test/jobs
parent9cfcc067e626f0f1e220cc00a9f96622a936350d (diff)
downloadrails-154057b4f7d8bcf37637ec7185ede3c4d0cd6583.tar.gz
rails-154057b4f7d8bcf37637ec7185ede3c4d0cd6583.tar.bz2
rails-154057b4f7d8bcf37637ec7185ede3c4d0cd6583.zip
Rewrite ActiveJob exception tests so it runs with the real adapters
Previously, by extending ActiveJob::TestCase, the test adapter provided for tests was being used always, in all executions where supposedly different adapters were being used. As a consequence, some bugs visible only for some adapters might have gone undetected. This commit changes that, skipping queue adapters for which we can't test scheduling jobs with a delay.
Diffstat (limited to 'activejob/test/jobs')
-rw-r--r--activejob/test/jobs/retry_job.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/activejob/test/jobs/retry_job.rb b/activejob/test/jobs/retry_job.rb
index 3b0dce1a3c..112d672006 100644
--- a/activejob/test/jobs/retry_job.rb
+++ b/activejob/test/jobs/retry_job.rb
@@ -30,7 +30,13 @@ class RetryJob < ActiveJob::Base
discard_on FirstDiscardableErrorOfTwo, SecondDiscardableErrorOfTwo
discard_on(CustomDiscardableError) { |job, error| JobBuffer.add("Dealt with a job that was discarded in a custom way. Message: #{error.message}") }
- def perform(raising, attempts)
+ before_enqueue do |job|
+ if job.arguments.include?(:log_scheduled_at) && job.scheduled_at
+ JobBuffer.add("Next execution scheduled at #{job.scheduled_at}")
+ end
+ end
+
+ def perform(raising, attempts, *)
raising = raising.shift if raising.is_a?(Array)
if raising && executions < attempts
JobBuffer.add("Raised #{raising} for the #{executions.ordinalize} time")