feat(default.queues): mailers that are not critical are low, otherwise critical. analysis is default, purge is low

This commit is contained in:
mfo 2024-09-24 21:25:10 +02:00
parent afe98704e9
commit b8b727f06b
No known key found for this signature in database
GPG key ID: 7CE3E1F5B794A8EC
5 changed files with 12 additions and 20 deletions

View file

@ -12,7 +12,7 @@ class PriorizedMailDeliveryJob < ActionMailer::MailDeliveryJob
end
end
def custom_queue # should be low
ENV.fetch('BULK_EMAIL_QUEUE') { Rails.application.config.action_mailer.deliver_later_queue_name.to_s }
def custom_queue
'low'
end
end

View file

@ -53,14 +53,14 @@ module TPS
config.action_dispatch.ip_spoofing_check = false
# Set the queue name for the mail delivery jobs to 'mailers'
config.action_mailer.deliver_later_queue_name = 'mailers'
config.action_mailer.deliver_later_queue_name = 'critical' # otherwise, :low
# Allow the error messages format to be customized
config.active_model.i18n_customize_full_message = true
# Set the queue name for the analysis jobs to 'active_storage_analysis'
config.active_storage.queues.analysis = :active_storage_analysis
config.active_storage.queues.purge = :purge
config.active_storage.queues.analysis = :default
config.active_storage.queues.purge = :low
config.active_support.cache_format_version = 7.0

View file

@ -11,8 +11,7 @@ RSpec.describe AdministrateurMailer, type: :mailer do
it { expect(subject.subject).to include("La suppression automatique des dossiers a été activée sur la démarche") }
context 'when perform_later is called' do
let(:custom_queue) { 'low_priority' }
before { ENV['BULK_EMAIL_QUEUE'] = custom_queue }
let(:custom_queue) { 'low' }
it 'enqueues email is custom queue for low priority delivery' do
expect { subject.deliver_later }.to have_enqueued_job.on_queue(custom_queue)
end
@ -52,8 +51,7 @@ end
it { expect(subject.body).to include("un de vos services n'a pas son siret renseigné") }
context 'when perform_later is called' do
let(:custom_queue) { 'low_priority' }
before { ENV['BULK_EMAIL_QUEUE'] = custom_queue }
let(:custom_queue) { 'low' }
it 'enqueues email is custom queue for low priority delivery' do
expect { subject.deliver_later }.to have_enqueued_job.on_queue(custom_queue)
end

View file

@ -10,8 +10,7 @@ RSpec.describe InstructeurMailer, type: :mailer do
it { expect(subject.body).to include('Bonjour') }
context 'when perform_later is called' do
let(:custom_queue) { 'low_priority' }
before { ENV['BULK_EMAIL_QUEUE'] = custom_queue }
let(:custom_queue) { 'low' }
it 'enqueues email is custom queue for low priority delivery' do
expect { subject.deliver_later }.to have_enqueued_job(PriorizedMailDeliveryJob).on_queue(custom_queue)
@ -81,9 +80,7 @@ RSpec.describe InstructeurMailer, type: :mailer do
end
context 'when perform_later is called' do
let(:custom_queue) { 'low_priority' }
before { ENV['BULK_EMAIL_QUEUE'] = custom_queue }
let(:custom_queue) { 'low' }
it 'enqueues email is custom queue for low priority delivery' do
expect { subject.deliver_later }.to have_enqueued_job.on_queue(custom_queue)
end

View file

@ -151,8 +151,7 @@ RSpec.describe UserMailer, type: :mailer do
context 'when perform_later is called' do
let(:role) { administrateurs(:default_admin) }
let(:custom_queue) { 'low_priority' }
before { ENV['BULK_EMAIL_QUEUE'] = custom_queue }
let(:custom_queue) { 'low' }
it 'enqueues email is custom queue for low priority delivery' do
expect { subject.deliver_later }.to have_enqueued_job.on_queue(custom_queue)
end
@ -168,8 +167,7 @@ RSpec.describe UserMailer, type: :mailer do
end
context 'when perform_later is called' do
let(:custom_queue) { 'low_priority' }
before { ENV['BULK_EMAIL_QUEUE'] = custom_queue }
let(:custom_queue) { 'low' }
it 'enqueues email is custom queue for low priority delivery' do
expect { subject.deliver_later }.to have_enqueued_job.on_queue(custom_queue)
end
@ -188,8 +186,7 @@ RSpec.describe UserMailer, type: :mailer do
end
context 'when perform_later is called' do
let(:custom_queue) { 'low_priority' }
before { ENV['BULK_EMAIL_QUEUE'] = custom_queue }
let(:custom_queue) { 'low' }
it 'enqueues email is custom queue for low priority delivery' do
expect { subject.deliver_later }.to have_enqueued_job.on_queue(custom_queue)
end