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
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