Merge pull request #10467 from tchak/fix-multi-termine-batch
fix(dossier): batch operations to termine dossier should send emails
This commit is contained in:
commit
bdee62adc3
2 changed files with 24 additions and 4 deletions
|
@ -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)
|
||||
|
|
|
@ -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) }
|
||||
|
|
Loading…
Reference in a new issue