diff options
Diffstat (limited to 'activejob/test/cases/exceptions_test.rb')
-rw-r--r-- | activejob/test/cases/exceptions_test.rb | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/activejob/test/cases/exceptions_test.rb b/activejob/test/cases/exceptions_test.rb index 58d87a339a..9ee1dbfa0a 100644 --- a/activejob/test/cases/exceptions_test.rb +++ b/activejob/test/cases/exceptions_test.rb @@ -1,5 +1,5 @@ -require 'helper' -require 'jobs/retry_job' +require "helper" +require "jobs/retry_job" class ExceptionsTest < ActiveJob::TestCase setup do @@ -9,7 +9,7 @@ class ExceptionsTest < ActiveJob::TestCase test "successfully retry job throwing exception against defaults" do perform_enqueued_jobs do - RetryJob.perform_later 'DefaultsError', 5 + RetryJob.perform_later "DefaultsError", 5 assert_equal [ "Raised DefaultsError for the 1st time", @@ -22,7 +22,7 @@ class ExceptionsTest < ActiveJob::TestCase test "successfully retry job throwing exception against higher limit" do perform_enqueued_jobs do - RetryJob.perform_later 'ShortWaitTenAttemptsError', 9 + RetryJob.perform_later "ShortWaitTenAttemptsError", 9 assert_equal 9, JobBuffer.values.count end end @@ -30,7 +30,7 @@ class ExceptionsTest < ActiveJob::TestCase test "failed retry job when exception kept occurring against defaults" do perform_enqueued_jobs do begin - RetryJob.perform_later 'DefaultsError', 6 + RetryJob.perform_later "DefaultsError", 6 assert_equal "Raised DefaultsError for the 5th time", JobBuffer.last_value rescue DefaultsError pass @@ -41,7 +41,7 @@ class ExceptionsTest < ActiveJob::TestCase test "failed retry job when exception kept occurring against higher limit" do perform_enqueued_jobs do begin - RetryJob.perform_later 'ShortWaitTenAttemptsError', 11 + RetryJob.perform_later "ShortWaitTenAttemptsError", 11 assert_equal "Raised ShortWaitTenAttemptsError for the 10th time", JobBuffer.last_value rescue ShortWaitTenAttemptsError pass @@ -51,7 +51,7 @@ class ExceptionsTest < ActiveJob::TestCase test "discard job" do perform_enqueued_jobs do - RetryJob.perform_later 'DiscardableError', 2 + RetryJob.perform_later "DiscardableError", 2 assert_equal "Raised DiscardableError for the 1st time", JobBuffer.last_value end end @@ -59,16 +59,16 @@ class ExceptionsTest < ActiveJob::TestCase test "custom handling of job that exceeds retry attempts" do perform_enqueued_jobs do RetryJob.perform_later 'CustomCatchError', 6 - assert_equal "Dealt with a job that failed to retry in a custom way", JobBuffer.last_value + assert_equal "Dealt with a job that failed to retry in a custom way after 6 attempts", JobBuffer.last_value end end test "long wait job" do travel_to Time.now - + perform_enqueued_jobs do assert_performed_with at: (Time.now + 3600.seconds).to_i do - RetryJob.perform_later 'LongWaitError', 5 + RetryJob.perform_later "LongWaitError", 5 end end end @@ -78,13 +78,13 @@ class ExceptionsTest < ActiveJob::TestCase perform_enqueued_jobs do assert_performed_with at: (Time.now + 3.seconds).to_i do - assert_performed_with at: (Time.now + 18.seconds).to_i do - assert_performed_with at: (Time.now + 83.seconds).to_i do - assert_performed_with at: (Time.now + 258.seconds).to_i do - RetryJob.perform_later 'ExponentialWaitTenAttemptsError', 5 - end - end - end + assert_performed_with at: (Time.now + 18.seconds).to_i do + assert_performed_with at: (Time.now + 83.seconds).to_i do + assert_performed_with at: (Time.now + 258.seconds).to_i do + RetryJob.perform_later "ExponentialWaitTenAttemptsError", 5 + end + end + end end end end @@ -94,13 +94,13 @@ class ExceptionsTest < ActiveJob::TestCase perform_enqueued_jobs do assert_performed_with at: (Time.now + 2.seconds).to_i do - assert_performed_with at: (Time.now + 4.seconds).to_i do - assert_performed_with at: (Time.now + 6.seconds).to_i do - assert_performed_with at: (Time.now + 8.seconds).to_i do - RetryJob.perform_later 'CustomWaitTenAttemptsError', 5 - end - end - end + assert_performed_with at: (Time.now + 4.seconds).to_i do + assert_performed_with at: (Time.now + 6.seconds).to_i do + assert_performed_with at: (Time.now + 8.seconds).to_i do + RetryJob.perform_later "CustomWaitTenAttemptsError", 5 + end + end + end end end end |