[Fix #554] If procedure is hidden, then don't crash
This commit is contained in:
parent
62832f079a
commit
aa929bb5b2
2 changed files with 8 additions and 2 deletions
|
@ -39,7 +39,7 @@ class Users::DossiersController < UsersController
|
|||
unless params[:procedure_path].nil?
|
||||
procedure_path = ProcedurePath.where(path: params[:procedure_path]).last
|
||||
|
||||
if procedure_path.nil?
|
||||
if procedure_path.nil? || procedure_path.procedure.nil?
|
||||
flash.alert = "Procédure inconnue"
|
||||
return redirect_to root_path
|
||||
else
|
||||
|
|
|
@ -152,7 +152,7 @@ describe Users::DossiersController, type: :controller do
|
|||
end
|
||||
|
||||
describe 'GET #commencer' do
|
||||
subject { get :commencer, params: {procedure_path: procedure.path} }
|
||||
subject { get :commencer, params: { procedure_path: procedure.path } }
|
||||
|
||||
it { expect(subject.status).to eq 302 }
|
||||
it { expect(subject).to redirect_to new_users_dossier_path(procedure_id: procedure.id) }
|
||||
|
@ -166,6 +166,12 @@ describe Users::DossiersController, type: :controller do
|
|||
|
||||
it { expect(subject.status).to eq 200 }
|
||||
end
|
||||
|
||||
context 'when procedure is hidden' do
|
||||
let(:procedure) { create(:procedure, :published, hidden_at: DateTime.now) }
|
||||
|
||||
it { expect(subject).to redirect_to(root_path) }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #siret_informations' do
|
||||
|
|
Loading…
Reference in a new issue