Merge pull request #10243 from demarches-simplifiees/small_job_fixes
Tech: petites corrections pour éviter les réessais inutile sur les jobs de mail et de rnf
This commit is contained in:
commit
61a6f0b382
3 changed files with 15 additions and 0 deletions
|
@ -1,4 +1,6 @@
|
|||
class PriorizedMailDeliveryJob < ActionMailer::MailDeliveryJob
|
||||
discard_on ActiveJob::DeserializationError
|
||||
|
||||
def queue_name
|
||||
mailer, action_name = @arguments
|
||||
if mailer.constantize.critical_email?(action_name)
|
||||
|
|
|
@ -8,6 +8,10 @@ class RNFService
|
|||
Success(body)
|
||||
in Failure(code:, reason:) if code.in?(401..403)
|
||||
Failure(API::Client::Error[:unauthorized, code, false, reason])
|
||||
# 400 errors are due to invalid rfn code
|
||||
# it cannot be fixed so we do not retry
|
||||
in Failure(code: 400, reason:)
|
||||
Failure(API::Client::Error[:bad_request, code, false, reason])
|
||||
else
|
||||
result
|
||||
end
|
||||
|
|
|
@ -72,6 +72,15 @@ describe Champs::RNFChamp, type: :model do
|
|||
expect(subject.failure.reason).to be_a(API::Client::HTTPError)
|
||||
}
|
||||
end
|
||||
|
||||
context 'failure (http 400)' do
|
||||
let(:status) { 400 }
|
||||
let(:response_type) { 'invalid' }
|
||||
it {
|
||||
expect(subject.failure.retryable).to be_falsey
|
||||
expect(subject.failure.reason).to be_a(API::Client::HTTPError)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
describe 'for_export' do
|
||||
|
|
Loading…
Reference in a new issue