Merge pull request #555 from sgmap/fix_554

[Fix #554] If procedure is hidden, then don't crash
This commit is contained in:
gregoirenovel 2017-07-06 15:29:19 +02:00 committed by GitHub
commit a8528b2749
2 changed files with 8 additions and 2 deletions

View file

@ -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

View file

@ -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