This commit is contained in:
Xavier J 2015-10-26 18:08:41 +01:00
parent 9392f1d6e3
commit 5c643c6373
4 changed files with 8 additions and 10 deletions

View file

@ -5,7 +5,7 @@ class Users::CarteController < UsersController
@dossier = current_user_dossier @dossier = current_user_dossier
rescue ActiveRecord::RecordNotFound rescue ActiveRecord::RecordNotFound
flash.alert = t('errors.messages.dossier_not_found') flash.alert = t('errors.messages.dossier_not_found')
redirect_to url_for(controller: :dossiers, action: :index) redirect_to url_for(root_path)
end end
def save_ref_api_carto def save_ref_api_carto

View file

@ -4,6 +4,7 @@ describe Admin::ProceduresController, type: :controller do
let(:admin) { create(:administrateur) } let(:admin) { create(:administrateur) }
let(:bad_procedure_id) { 100000 } let(:bad_procedure_id) { 100000 }
let(:procedure_id) { 1 }
let(:libelle) { 'Procédure de test' } let(:libelle) { 'Procédure de test' }
let(:description) { 'Description de test' } let(:description) { 'Description de test' }
@ -30,7 +31,7 @@ describe Admin::ProceduresController, type: :controller do
describe 'GET #show' do describe 'GET #show' do
let(:procedure) { create(:procedure) } let(:procedure) { create(:procedure) }
subject { get :show, id: procedure.id } subject { get :show, id: procedure_id }
context 'when user is not connected' do context 'when user is not connected' do
before do before do
@ -42,16 +43,14 @@ describe Admin::ProceduresController, type: :controller do
context 'when user is connected' do context 'when user is connected' do
context 'when procedure exist' do context 'when procedure exist' do
let(:procedure_id) { procedure.id }
it { expect(subject).to have_http_status(:success) } it { expect(subject).to have_http_status(:success) }
end end
context "when procedure doesn't exist" do context "when procedure doesn't exist" do
before do let(:procedure_id) { bad_procedure_id }
procedure.id = bad_procedure_id
end
it { expect(subject).to redirect_to admin_procedures_path } it { expect(subject).to redirect_to admin_procedures_path }
it { expect(flash[:alert]).to be_present }
end end
end end
end end

View file

@ -16,7 +16,6 @@ RSpec.describe Users::CarteController, type: :controller do
end end
describe 'GET #show' do describe 'GET #show' do
context 'user is not connected' do context 'user is not connected' do
before do before do
sign_out dossier.user sign_out dossier.user
@ -35,7 +34,7 @@ RSpec.describe Users::CarteController, type: :controller do
it 'redirection vers la liste des dossiers du user si dossier ID n\'existe pas' do it 'redirection vers la liste des dossiers du user si dossier ID n\'existe pas' do
get :show, dossier_id: bad_dossier_id get :show, dossier_id: bad_dossier_id
expect(response).to redirect_to(controller: :dossiers, action: :index) expect(response).to redirect_to(root_path)
end end
it_behaves_like "not owner of dossier", :show it_behaves_like "not owner of dossier", :show

View file

@ -29,8 +29,8 @@ describe Procedure do
end end
context 'lien_demarche' do context 'lien_demarche' do
it { is_expected.not_to allow_value(nil).for(:lien_demarche) } it { is_expected.to allow_value(nil).for(:lien_demarche) }
it { is_expected.not_to allow_value('').for(:lien_demarche) } it { is_expected.to allow_value('').for(:lien_demarche) }
it { is_expected.to allow_value('http://localhost').for(:lien_demarche) } it { is_expected.to allow_value('http://localhost').for(:lien_demarche) }
end end
end end