fix(sva): ensure "en construction" + "en instruction" notifications when submitting at submission
Pour le moment on conserve les 2 emails car l'email en construction contient des informations spécifiques : - l'attestation de dépôt - potentiellement un contenu spécifique car il provient d'un template Même remarque pour les démarches déclaratives.
This commit is contained in:
parent
4bdd4310ab
commit
30df476791
2 changed files with 23 additions and 4 deletions
|
@ -185,7 +185,7 @@ module Users
|
|||
if errors.blank?
|
||||
@dossier.passer_en_construction!
|
||||
@dossier.process_declarative!
|
||||
@dossier.process_sva_svr! # TODO no en construction email if SVA/SVR (and declarative?)
|
||||
@dossier.process_sva_svr!
|
||||
NotificationMailer.send_en_construction_notification(@dossier).deliver_later
|
||||
@dossier.groupe_instructeur.instructeurs.with_instant_email_dossier_notifications.each do |instructeur|
|
||||
DossierMailer.notify_new_dossier_depose_to_instructeur(@dossier, instructeur.email).deliver_later
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
describe Users::DossiersController, type: :controller do
|
||||
include ActiveSupport::Testing::TimeHelpers
|
||||
|
||||
let(:user) { create(:user) }
|
||||
|
||||
describe 'before_actions' do
|
||||
|
@ -351,10 +353,9 @@ describe Users::DossiersController, type: :controller do
|
|||
let(:payload) { { id: dossier.id } }
|
||||
|
||||
subject do
|
||||
Timecop.freeze(now) do
|
||||
travel_to now
|
||||
post :submit_brouillon, params: payload
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the dossier cannot be updated by the user' do
|
||||
let!(:dossier) { create(:dossier, :en_instruction, user: user) }
|
||||
|
@ -433,6 +434,24 @@ describe Users::DossiersController, type: :controller do
|
|||
it { expect(flash.alert).to eq("Vous n’avez pas accès à ce dossier") }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when procedure has sva enabled' do
|
||||
let(:procedure) { create(:procedure, :sva) }
|
||||
let!(:dossier) { create(:dossier, :brouillon, procedure:, user:) }
|
||||
|
||||
it 'passe automatiquement en instruction' do
|
||||
delivery = double.tap { expect(_1).to receive(:deliver_later).with(no_args).twice }
|
||||
expect(NotificationMailer).to receive(:send_en_construction_notification).and_return(delivery)
|
||||
expect(NotificationMailer).to receive(:send_en_instruction_notification).and_return(delivery)
|
||||
|
||||
subject
|
||||
dossier.reload
|
||||
|
||||
expect(dossier).to be_en_instruction
|
||||
expect(dossier.pending_correction?).to be_falsey
|
||||
expect(dossier.en_instruction_at).to within(5.seconds).of(Time.current)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#submit_en_construction' do
|
||||
|
|
Loading…
Reference in a new issue