From 86b04d4275fb0439d821a68fbe72a8889e10ff6b Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Wed, 9 Sep 2020 10:07:49 +0200 Subject: [PATCH] Add a missing test on job retry to the excon err --- spec/jobs/application_job_spec.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/spec/jobs/application_job_spec.rb b/spec/jobs/application_job_spec.rb index cb1b6ceac..8de03c541 100644 --- a/spec/jobs/application_job_spec.rb +++ b/spec/jobs/application_job_spec.rb @@ -13,7 +13,23 @@ RSpec.describe ApplicationJob, type: :job do end end + context 'when ::Excon::Error::BadRequest is raised' do + # https://api.rubyonrails.org/classes/ActiveJob/Exceptions/ClassMethods.html#method-i-retry_on + # retry on will try 5 times and then bubble up the error + it 'makes 5 attempts' do + assert_performed_jobs 5 do + ExconErrJob.perform_later rescue ::Excon::Error::BadRequest + end + end + end + class ChildJob < ApplicationJob def perform; end end + + class ExconErrJob < ApplicationJob + def perform + raise ::Excon::Error::BadRequest.new('bad request') + end + end end