Merge pull request #4723 from betagouv/fix-double-render

fix: les demandes de PDF pour les brouillons génèrent des DoubleRender
This commit is contained in:
Keirua 2020-01-29 14:33:33 +01:00 committed by GitHub
commit d4dbc44dac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View file

@ -33,6 +33,7 @@ module Users
def show def show
if dossier.brouillon? if dossier.brouillon?
redirect_to brouillon_dossier_path(dossier) redirect_to brouillon_dossier_path(dossier)
return
end end
@dossier = dossier @dossier = dossier

View file

@ -757,11 +757,17 @@ describe Users::DossiersController, type: :controller do
procedure: procedure, procedure: procedure,
user: user) user: user)
} }
subject! { get(:show, params: { id: dossier.id, format: :pdf }) } subject! { get(:show, params: { id: dossier.id, format: :pdf }) }
it { expect(assigns(:include_infos_administration)).to eq(false) } context 'when the dossier is a brouillon' do
it { expect(response).to render_template 'dossiers/show' } 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
end end