fix(dossier): batch operations to termine dossier should send emails

This commit is contained in:
Paul Chavard 2024-05-29 11:31:58 +02:00
parent 3b96970e05
commit 5154231ccf
No known key found for this signature in database
2 changed files with 24 additions and 4 deletions

View file

@ -82,13 +82,13 @@ class BatchOperation < ApplicationRecord
when BatchOperation.operations.fetch(:desarchiver)
dossier.desarchiver!
when BatchOperation.operations.fetch(:passer_en_instruction)
dossier.passer_en_instruction(instructeur: instructeur)
dossier.passer_en_instruction!(instructeur: instructeur)
when BatchOperation.operations.fetch(:accepter)
dossier.accepter(instructeur: instructeur, motivation: motivation, justificatif: justificatif_motivation)
dossier.accepter!(instructeur: instructeur, motivation: motivation, justificatif: justificatif_motivation)
when BatchOperation.operations.fetch(:refuser)
dossier.refuser(instructeur: instructeur, motivation: motivation, justificatif: justificatif_motivation)
dossier.refuser!(instructeur: instructeur, motivation: motivation, justificatif: justificatif_motivation)
when BatchOperation.operations.fetch(:classer_sans_suite)
dossier.classer_sans_suite(instructeur: instructeur, motivation: motivation, justificatif: justificatif_motivation)
dossier.classer_sans_suite!(instructeur: instructeur, motivation: motivation, justificatif: justificatif_motivation)
when BatchOperation.operations.fetch(:follow)
instructeur.follow(dossier)
when BatchOperation.operations.fetch(:repousser_expiration)

View file

@ -233,6 +233,26 @@ describe BatchOperation, type: :model do
end
end
describe '#process_one' do
let(:dossier) { create(:dossier, :en_instruction, :with_individual) }
subject { create(:batch_operation, operation, instructeur: create(:instructeur)) }
context 'accepter' do
let(:operation) { :accepter }
it { expect { subject.process_one(dossier) }.to have_enqueued_job.on_queue(Rails.application.config.action_mailer.deliver_later_queue_name) }
end
context 'refuser' do
let(:operation) { :refuser }
it { expect { subject.process_one(dossier) }.to have_enqueued_job.on_queue(Rails.application.config.action_mailer.deliver_later_queue_name) }
end
context 'classer_sans_suite' do
let(:operation) { :classer_sans_suite }
it { expect { subject.process_one(dossier) }.to have_enqueued_job.on_queue(Rails.application.config.action_mailer.deliver_later_queue_name) }
end
end
describe 'stale' do
let(:finished_at) { 6.hours.ago }
let(:staled_batch_operation) { create(:batch_operation, operation: :archiver, finished_at: 2.days.ago, updated_at: 2.days.ago) }