diff --git a/app/models/batch_operation.rb b/app/models/batch_operation.rb index 07e3c113d..f6abad9b1 100644 --- a/app/models/batch_operation.rb +++ b/app/models/batch_operation.rb @@ -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) diff --git a/spec/models/batch_operation_spec.rb b/spec/models/batch_operation_spec.rb index 8120c122c..da24e7b38 100644 --- a/spec/models/batch_operation_spec.rb +++ b/spec/models/batch_operation_spec.rb @@ -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) }