bug(commencer/test): with procedure without service nor organisation, it crashes

This commit is contained in:
Martin 2022-04-28 13:57:19 +02:00 committed by mfo
parent 1745f45f0c
commit 2529773515
2 changed files with 12 additions and 4 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

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