Merge pull request #7208 from betagouv/fix/sentry#3229941628

bug(commencer/test): with procedure without service nor organisation, it crashes
This commit is contained in:
mfo 2022-04-28 14:29:35 +02:00 committed by GitHub
commit 1e0efcc4ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 5 deletions

View file

@ -84,8 +84,8 @@ module Users
def generate_empty_pdf(revision)
@dossier = revision.new_dossier
s = render_to_string(template: 'dossiers/dossier_vide', formats: [:pdf])
send_data(s, :filename => "#{revision.procedure.libelle}.pdf")
data = render_to_string(template: 'dossiers/dossier_vide', formats: [:pdf])
send_data(data, filename: "#{revision.procedure.libelle}.pdf")
end
end
end

View file

@ -185,7 +185,7 @@ prawn_document(page_size: "A4") do |pdf|
pdf.move_down(40)
render_in_2_columns(pdf, 'Démarche', @dossier.procedure.libelle)
render_in_2_columns(pdf, 'Organisme', @dossier.procedure.organisation_name)
render_in_2_columns(pdf, 'Organisme', @dossier.procedure.organisation_name || "En attente de saisi")
pdf.text "\n"
add_title(pdf, "Identité du demandeur")

View file

@ -181,15 +181,23 @@ describe Users::CommencerController, type: :controller do
end
describe '#dossier_vide_test_pdf' do
before { get :dossier_vide_pdf_test, params: { path: procedure.path } }
render_views
before { get :dossier_vide_pdf_test, params: { path: procedure.path }, format: :pdf }
context 'not published procedure' do
context 'not published procedure with service' do
let(:procedure) { create(:procedure, :with_service, :with_path) }
it 'works' do
expect(response).to have_http_status(:success)
end
end
context 'not published procedure without service' do
let(:procedure) { create(:procedure, :with_path, service: nil, organisation: nil) }
it 'works' do
expect(response).to have_http_status(:success)
end
end
context 'published procedure' do
let(:procedure) { create(:procedure, :published, :with_service, :with_path) }
it 'redirect to procedure not found' do