From 154057b4f7d8bcf37637ec7185ede3c4d0cd6583 Mon Sep 17 00:00:00 2001 From: Rosa Gutierrez Date: Mon, 7 Jan 2019 14:36:56 +0100 Subject: 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. --- activejob/test/jobs/retry_job.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'activejob/test/jobs') 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") -- cgit v1.2.3