From 1c3573c7db8c862eccf10b9c61a32c6d971965ea Mon Sep 17 00:00:00 2001 From: clemkeirua Date: Wed, 29 Jan 2020 10:26:26 +0100 Subject: [PATCH] fix DoubleRender error for brouillon pdf --- app/controllers/users/dossiers_controller.rb | 1 + spec/controllers/users/dossiers_controller_spec.rb | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb index f171e94fa..fac36c1c7 100644 --- a/app/controllers/users/dossiers_controller.rb +++ b/app/controllers/users/dossiers_controller.rb @@ -33,6 +33,7 @@ module Users def show if dossier.brouillon? redirect_to brouillon_dossier_path(dossier) + return end @dossier = dossier diff --git a/spec/controllers/users/dossiers_controller_spec.rb b/spec/controllers/users/dossiers_controller_spec.rb index cdd9f3d90..b0e34bc9b 100644 --- a/spec/controllers/users/dossiers_controller_spec.rb +++ b/spec/controllers/users/dossiers_controller_spec.rb @@ -757,11 +757,17 @@ describe Users::DossiersController, type: :controller do procedure: procedure, user: user) } - subject! { get(:show, params: { id: dossier.id, format: :pdf }) } - it { expect(assigns(:include_infos_administration)).to eq(false) } - it { expect(response).to render_template 'dossiers/show' } + context 'when the dossier is a brouillon' do + let(:dossier) { create(:dossier, user: user) } + it { is_expected.to redirect_to(brouillon_dossier_path(dossier)) } + end + + context 'when the dossier has been submitted' do + it { expect(assigns(:include_infos_administration)).to eq(false) } + it { expect(response).to render_template 'dossiers/show' } + end end end