create AR email and send it at the right time

This commit is contained in:
Lisa Durand 2024-03-21 15:03:20 +01:00
parent ee91f47c5a
commit ae08044ff2
8 changed files with 112 additions and 11 deletions

View file

@ -6,7 +6,9 @@ describe Instructeurs::DossiersController, type: :controller do
let(:administration) { create(:administration) }
let(:instructeurs) { [instructeur] }
let(:procedure) { create(:procedure, :published, :for_individual, instructeurs: instructeurs) }
let(:procedure_accuse_lecture) { create(:procedure, :published, :for_individual, :accuse_lecture, instructeurs: instructeurs) }
let(:dossier) { create(:dossier, :en_construction, :with_individual, procedure: procedure) }
let(:dossier_accuse_lecture) { create(:dossier, :en_construction, :with_individual, procedure: procedure_accuse_lecture) }
let(:dossier_for_tiers) { create(:dossier, :en_construction, :for_tiers_with_notification, procedure: procedure) }
let(:dossier_for_tiers_without_notif) { create(:dossier, :en_construction, :for_tiers_without_notification, procedure: procedure) }
let(:fake_justificatif) { fixture_file_upload('spec/fixtures/files/piece_justificative_0.pdf', 'application/pdf') }
@ -376,6 +378,29 @@ describe Instructeurs::DossiersController, type: :controller do
end
end
context "with accuse de lecture procedure" do
before do
dossier_accuse_lecture.passer_en_instruction!(instructeur: instructeur)
sign_in(instructeur.user)
end
context 'with classer_sans_suite' do
subject { post :terminer, params: { process_action: "classer_sans_suite", procedure_id: procedure_accuse_lecture.id, dossier_id: dossier_accuse_lecture.id }, format: :turbo_stream }
it 'Notification accuse de lecture email is sent and not the others' do
expect(NotificationMailer).to receive(:send_accuse_lecture_notification)
.with(dossier_accuse_lecture).and_return(NotificationMailer)
expect(NotificationMailer).to receive(:deliver_later)
expect(NotificationMailer).not_to receive(:send_sans_suite_notification)
.with(dossier_accuse_lecture)
subject
end
it { expect(subject.body).to include('header-top') }
end
end
context "with classer_sans_suite" do
before do
dossier.passer_en_instruction!(instructeur: instructeur)