Merge pull request #2304 from betagouv/fix_sentry_2755

Fix Sentry error 2755
This commit is contained in:
Paul Chavard 2018-07-26 18:50:10 +02:00 committed by GitHub
commit 87dcec9908
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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 NotificationMailer.send_without_continuation_notification(dossier).deliver_later
when "accepter" when "accepter"
dossier.accepte! dossier.accepte!
if dossier.attestation.nil?
dossier.attestation = dossier.build_attestation dossier.attestation = dossier.build_attestation
dossier.save dossier.save
end
flash.notice = "Dossier traité avec succès." flash.notice = "Dossier traité avec succès."
NotificationMailer.send_closed_notification(dossier).deliver_later NotificationMailer.send_closed_notification(dossier).deliver_later
end 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) is_expected.to redirect_to redirect_to gestionnaire_dossier_path(procedure, dossier)
end 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 end
context 'when the attestation template uses the motivation field' do context 'when the attestation template uses the motivation field' do