dossier: make Dossiers#show a stub redirecting to the correct location
This commit is contained in:
parent
f37a628b44
commit
0ac28da207
3 changed files with 26 additions and 3 deletions
|
@ -4,8 +4,8 @@ module NewUser
|
||||||
|
|
||||||
helper_method :new_demarche_url
|
helper_method :new_demarche_url
|
||||||
|
|
||||||
before_action :ensure_ownership!, except: [:index, :modifier, :update, :recherche]
|
before_action :ensure_ownership!, except: [:index, :show, :modifier, :update, :recherche]
|
||||||
before_action :ensure_ownership_or_invitation!, only: [:modifier, :update]
|
before_action :ensure_ownership_or_invitation!, only: [:show, :modifier, :update]
|
||||||
before_action :ensure_dossier_can_be_updated, only: [:update_identite, :update]
|
before_action :ensure_dossier_can_be_updated, only: [:update_identite, :update]
|
||||||
before_action :forbid_invite_submission!, only: [:update]
|
before_action :forbid_invite_submission!, only: [:update]
|
||||||
|
|
||||||
|
@ -23,6 +23,14 @@ module NewUser
|
||||||
end
|
end
|
||||||
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
|
def attestation
|
||||||
send_data(dossier.attestation.pdf.read, filename: 'attestation.pdf', type: 'application/pdf')
|
send_data(dossier.attestation.pdf.read, filename: 'attestation.pdf', type: 'application/pdf')
|
||||||
end
|
end
|
||||||
|
|
|
@ -267,7 +267,7 @@ Rails.application.routes.draw do
|
||||||
#
|
#
|
||||||
|
|
||||||
scope module: 'new_user' do
|
scope module: 'new_user' do
|
||||||
resources :dossiers, only: [:index, :update] do
|
resources :dossiers, only: [:index, :show, :update] do
|
||||||
member do
|
member do
|
||||||
get 'identite'
|
get 'identite'
|
||||||
patch 'update_identite'
|
patch 'update_identite'
|
||||||
|
|
|
@ -478,6 +478,21 @@ describe NewUser::DossiersController, type: :controller do
|
||||||
end
|
end
|
||||||
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
|
describe '#ask_deletion' do
|
||||||
before { sign_in(user) }
|
before { sign_in(user) }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue