diff --git a/app/controllers/new_user/dossiers_controller.rb b/app/controllers/new_user/dossiers_controller.rb index 595bc2ac9..478378867 100644 --- a/app/controllers/new_user/dossiers_controller.rb +++ b/app/controllers/new_user/dossiers_controller.rb @@ -4,8 +4,8 @@ module NewUser helper_method :new_demarche_url - before_action :ensure_ownership!, except: [:index, :modifier, :update, :recherche] - before_action :ensure_ownership_or_invitation!, only: [:modifier, :update] + before_action :ensure_ownership!, except: [:index, :show, :modifier, :update, :recherche] + before_action :ensure_ownership_or_invitation!, only: [:show, :modifier, :update] before_action :ensure_dossier_can_be_updated, only: [:update_identite, :update] before_action :forbid_invite_submission!, only: [:update] @@ -23,6 +23,14 @@ module NewUser end end + def show + if dossier.brouillon? + redirect_to modifier_dossier_path(dossier) + else + redirect_to users_dossier_recapitulatif_path(dossier) + end + end + def attestation send_data(dossier.attestation.pdf.read, filename: 'attestation.pdf', type: 'application/pdf') end diff --git a/config/routes.rb b/config/routes.rb index ce2bf183c..6e230dcb8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -267,7 +267,7 @@ Rails.application.routes.draw do # scope module: 'new_user' do - resources :dossiers, only: [:index, :update] do + resources :dossiers, only: [:index, :show, :update] do member do get 'identite' patch 'update_identite' diff --git a/spec/controllers/new_user/dossiers_controller_spec.rb b/spec/controllers/new_user/dossiers_controller_spec.rb index a3605c7d2..17f18cc1f 100644 --- a/spec/controllers/new_user/dossiers_controller_spec.rb +++ b/spec/controllers/new_user/dossiers_controller_spec.rb @@ -478,6 +478,21 @@ describe NewUser::DossiersController, type: :controller do end end + describe '#show' do + before { sign_in(user) } + subject! { get(:show, params: { id: dossier.id }) } + + context 'when the dossier is a brouillon' do + let(:dossier) { create(:dossier, user: user) } + it { is_expected.to redirect_to(modifier_dossier_path(dossier)) } + end + + context 'when the dossier has been submitted' do + let(:dossier) { create(:dossier, :en_construction, user: user) } + it { is_expected.to redirect_to(users_dossier_recapitulatif_path(dossier)) } + end + end + describe '#ask_deletion' do before { sign_in(user) }