Fix Sentry error 2755

This commit is contained in:
Mathieu Magnin 2018-07-25 17:16:24 +02:00
parent 647a445246
commit 84937e3d43
2 changed files with 12 additions and 2 deletions

View file

@ -101,8 +101,10 @@ module NewGestionnaire
NotificationMailer.send_without_continuation_notification(dossier).deliver_later
when "accepter"
dossier.accepte!
dossier.attestation = dossier.build_attestation
dossier.save
if dossier.attestation.nil?
dossier.attestation = dossier.build_attestation
dossier.save
end
flash.notice = "Dossier traité avec succès."
NotificationMailer.send_closed_notification(dossier).deliver_later
end

View file

@ -227,6 +227,14 @@ describe NewGestionnaire::DossiersController, type: :controller do
is_expected.to redirect_to redirect_to gestionnaire_dossier_path(procedure, dossier)
end
context 'and the dossier has already an attestation' do
it 'should not crash' do
dossier.attestation = Attestation.new
dossier.save
expect(subject).to redirect_to redirect_to gestionnaire_dossier_path(procedure, dossier)
end
end
end
context 'when the attestation template uses the motivation field' do