rend plus actionnable message d'erreur
This commit is contained in:
parent
4f4e68719a
commit
20d0585e31
4 changed files with 37 additions and 11 deletions
|
@ -596,7 +596,7 @@ module Users
|
||||||
end
|
end
|
||||||
|
|
||||||
def forbidden!
|
def forbidden!
|
||||||
flash[:alert] = t('users.dossiers.no_access')
|
flash[:alert] = t('users.dossiers.no_access_html', email: current_user.email)
|
||||||
redirect_to root_path
|
redirect_to root_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -756,7 +756,7 @@ en:
|
||||||
users:
|
users:
|
||||||
dossiers:
|
dossiers:
|
||||||
test_procedure: "This file is submitted on a test procedure. Any modification of the procedure by the administrator (addition of a field, publication of the procedure, etc.) will result in the removal of the file."
|
test_procedure: "This file is submitted on a test procedure. Any modification of the procedure by the administrator (addition of a field, publication of the procedure, etc.) will result in the removal of the file."
|
||||||
no_access: "You do not have access to this file"
|
no_access_html: "You do not have access to this file.<br>Check that you were signed in as <b>%{email}</b> to fill this procedure.<br>If not, please log off"
|
||||||
no_longer_editable: "Your file can no longer be edited"
|
no_longer_editable: "Your file can no longer be edited"
|
||||||
en_construction_submitted: "The modifications have already been submitted"
|
en_construction_submitted: "The modifications have already been submitted"
|
||||||
fill_identity:
|
fill_identity:
|
||||||
|
|
|
@ -759,7 +759,7 @@ fr:
|
||||||
users:
|
users:
|
||||||
dossiers:
|
dossiers:
|
||||||
test_procedure: "Ce dossier est déposé sur une démarche en test. Toute modification de la démarche par l’administrateur (ajout d’un champ, publication de la démarche...) entraînera sa suppression."
|
test_procedure: "Ce dossier est déposé sur une démarche en test. Toute modification de la démarche par l’administrateur (ajout d’un champ, publication de la démarche...) entraînera sa suppression."
|
||||||
no_access: "Vous n’avez pas accès à ce dossier"
|
no_access_html: "Vous n’avez pas accès à ce dossier.<br>Vérifiez que votre adresse email de connexion <b>%{email}</b> est bien celle utilisée pour remplir cette démarche.<br> Si ce n'est pas le cas, déconnectez-vous"
|
||||||
no_longer_editable: "Votre dossier ne peut plus être modifié"
|
no_longer_editable: "Votre dossier ne peut plus être modifié"
|
||||||
en_construction_submitted: "Les modifications ont déjà été déposées"
|
en_construction_submitted: "Les modifications ont déjà été déposées"
|
||||||
fill_identity:
|
fill_identity:
|
||||||
|
|
|
@ -25,7 +25,7 @@ describe Users::DossiersController, type: :controller do
|
||||||
before { @controller.send(ensure_authorized) }
|
before { @controller.send(ensure_authorized) }
|
||||||
|
|
||||||
it { expect(@controller).to have_received(:redirect_to).with(root_path) }
|
it { expect(@controller).to have_received(:redirect_to).with(root_path) }
|
||||||
it { expect(flash.alert).to eq("Vous n’avez pas accès à ce dossier") }
|
it { expect(flash.alert).to include("Vous n’avez pas accès à ce dossier") }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#ensure_ownership!' do
|
describe '#ensure_ownership!' do
|
||||||
|
@ -35,28 +35,41 @@ describe Users::DossiersController, type: :controller do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
@controller.params = @controller.params.merge(dossier_id: asked_dossier.id)
|
@controller.params = @controller.params.merge(dossier_id: asked_dossier.id)
|
||||||
expect(@controller).to receive(:current_user).and_return(user)
|
|
||||||
allow(@controller).to receive(:redirect_to)
|
allow(@controller).to receive(:redirect_to)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when a user asks for their own dossier' do
|
context 'when a user asks for their own dossier' do
|
||||||
|
before do
|
||||||
|
expect(@controller).to receive(:current_user).and_return(user)
|
||||||
|
end
|
||||||
|
|
||||||
let(:asked_dossier) { create(:dossier, user: user) }
|
let(:asked_dossier) { create(:dossier, user: user) }
|
||||||
|
|
||||||
it_behaves_like 'does not redirect nor flash'
|
it_behaves_like 'does not redirect nor flash'
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when a user asks for another dossier' do
|
context 'when a user asks for another dossier' do
|
||||||
|
before do
|
||||||
|
expect(@controller).to receive(:current_user).twice.and_return(user)
|
||||||
|
end
|
||||||
|
|
||||||
it_behaves_like 'redirects and flashes'
|
it_behaves_like 'redirects and flashes'
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when an invite asks for a dossier where they were invited' do
|
context 'when an invite asks for a dossier where they were invited' do
|
||||||
before { create(:invite, dossier: asked_dossier, user: user) }
|
before do
|
||||||
|
expect(@controller).to receive(:current_user).twice.and_return(user)
|
||||||
|
create(:invite, dossier: asked_dossier, user: user)
|
||||||
|
end
|
||||||
|
|
||||||
it_behaves_like 'redirects and flashes'
|
it_behaves_like 'redirects and flashes'
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when an invite asks for another dossier' do
|
context 'when an invite asks for another dossier' do
|
||||||
before { create(:invite, dossier: create(:dossier), user: user) }
|
before do
|
||||||
|
expect(@controller).to receive(:current_user).twice.and_return(user)
|
||||||
|
create(:invite, dossier: create(:dossier), user: user)
|
||||||
|
end
|
||||||
|
|
||||||
it_behaves_like 'redirects and flashes'
|
it_behaves_like 'redirects and flashes'
|
||||||
end
|
end
|
||||||
|
@ -69,28 +82,41 @@ describe Users::DossiersController, type: :controller do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
@controller.params = @controller.params.merge(dossier_id: asked_dossier.id)
|
@controller.params = @controller.params.merge(dossier_id: asked_dossier.id)
|
||||||
expect(@controller).to receive(:current_user).and_return(user)
|
|
||||||
allow(@controller).to receive(:redirect_to)
|
allow(@controller).to receive(:redirect_to)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when a user asks for their own dossier' do
|
context 'when a user asks for their own dossier' do
|
||||||
|
before do
|
||||||
|
expect(@controller).to receive(:current_user).and_return(user)
|
||||||
|
end
|
||||||
|
|
||||||
let(:asked_dossier) { create(:dossier, user: user) }
|
let(:asked_dossier) { create(:dossier, user: user) }
|
||||||
|
|
||||||
it_behaves_like 'does not redirect nor flash'
|
it_behaves_like 'does not redirect nor flash'
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when a user asks for another dossier' do
|
context 'when a user asks for another dossier' do
|
||||||
|
before do
|
||||||
|
expect(@controller).to receive(:current_user).twice.and_return(user)
|
||||||
|
end
|
||||||
|
|
||||||
it_behaves_like 'redirects and flashes'
|
it_behaves_like 'redirects and flashes'
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when an invite asks for a dossier where they were invited' do
|
context 'when an invite asks for a dossier where they were invited' do
|
||||||
before { create(:invite, dossier: asked_dossier, user: user) }
|
before do
|
||||||
|
expect(@controller).to receive(:current_user).and_return(user)
|
||||||
|
create(:invite, dossier: asked_dossier, user: user)
|
||||||
|
end
|
||||||
|
|
||||||
it_behaves_like 'does not redirect nor flash'
|
it_behaves_like 'does not redirect nor flash'
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when an invite asks for another dossier' do
|
context 'when an invite asks for another dossier' do
|
||||||
before { create(:invite, dossier: create(:dossier), user: user) }
|
before do
|
||||||
|
expect(@controller).to receive(:current_user).twice.and_return(user)
|
||||||
|
create(:invite, dossier: create(:dossier), user: user)
|
||||||
|
end
|
||||||
|
|
||||||
it_behaves_like 'redirects and flashes'
|
it_behaves_like 'redirects and flashes'
|
||||||
end
|
end
|
||||||
|
@ -431,7 +457,7 @@ describe Users::DossiersController, type: :controller do
|
||||||
before { subject }
|
before { subject }
|
||||||
|
|
||||||
it { expect(response).to redirect_to(root_path) }
|
it { expect(response).to redirect_to(root_path) }
|
||||||
it { expect(flash.alert).to eq("Vous n’avez pas accès à ce dossier") }
|
it { expect(flash.alert).to include("Vous n’avez pas accès à ce dossier") }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue