Merge pull request #9853 from mfo/US/fix-expert-link-to-dossiers
ETQ expert: lorsque je me connecte, je suis redirigé vers la page des avis, non pas vers la page de mes dossiers
This commit is contained in:
commit
9a5d908851
6 changed files with 28 additions and 4 deletions
|
@ -200,6 +200,7 @@ class ApplicationController < ActionController::Base
|
|||
roles = [
|
||||
current_user,
|
||||
current_instructeur,
|
||||
current_expert,
|
||||
current_administrateur,
|
||||
current_gestionnaire,
|
||||
current_super_admin
|
||||
|
|
|
@ -6,6 +6,8 @@ class RootController < ApplicationController
|
|||
return redirect_to admin_procedures_path
|
||||
elsif instructeur_signed_in?
|
||||
return redirect_to instructeur_procedures_path
|
||||
elsif expert_signed_in?
|
||||
return redirect_to expert_all_avis_path
|
||||
elsif user_signed_in?
|
||||
return redirect_to dossiers_path
|
||||
elsif super_admin_signed_in?
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
class TargetedUserLinksController < ApplicationController
|
||||
def show
|
||||
erase_user_location!
|
||||
store_user_location! if !user_signed_in?
|
||||
if targeted_user_link.invalid_signed_in_user?(current_user)
|
||||
render
|
||||
else
|
||||
|
@ -11,6 +13,14 @@ class TargetedUserLinksController < ApplicationController
|
|||
|
||||
private
|
||||
|
||||
def store_user_location!
|
||||
store_location_for(:user, request.fullpath)
|
||||
end
|
||||
|
||||
def erase_user_location!
|
||||
clear_stored_location_for(:user)
|
||||
end
|
||||
|
||||
def targeted_user_link
|
||||
@targeted_user_link ||= TargetedUserLink.find(params[:id])
|
||||
end
|
||||
|
|
|
@ -9,6 +9,16 @@ describe RootController, type: :controller do
|
|||
it { expect(subject).to redirect_to(dossiers_path) }
|
||||
end
|
||||
|
||||
context 'when Expert is connected' do
|
||||
let(:expert) { create(:expert) }
|
||||
|
||||
before do
|
||||
sign_in(expert.user)
|
||||
end
|
||||
|
||||
it { expect(subject).to redirect_to(expert_all_avis_path) }
|
||||
end
|
||||
|
||||
context 'when Instructeur is connected' do
|
||||
let(:instructeur) { create(:instructeur) }
|
||||
let(:procedure) { create(:procedure, :published) }
|
||||
|
|
|
@ -15,6 +15,7 @@ describe TargetedUserLinksController, type: :controller do
|
|||
|
||||
it 'redirects to expert_avis_url' do
|
||||
expect(response).to redirect_to(expert_avis_path(target_model.procedure, target_model))
|
||||
expect(controller.stored_location_for(:user)).to eq(controller.request.path)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ describe 'Inviting an expert:' do
|
|||
sign_in_with avis.expert.email, password
|
||||
|
||||
expect(page).to have_content('Connecté(e).')
|
||||
expect(page).to have_current_path(dossiers_path) # Ideally we'd want `expert_all_avis_path` instead
|
||||
expect(page).to have_current_path(expert_all_avis_path)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -52,9 +52,9 @@ describe 'Inviting an expert:' do
|
|||
expect(page).to have_current_path(new_user_session_path)
|
||||
login_as avis.expert.user, scope: :user
|
||||
sign_in_with(avis.expert.email, 'This is a very complicated password !')
|
||||
click_on 'Passer en expert'
|
||||
expect(page).to have_current_path(expert_all_avis_path)
|
||||
expect(page).to have_text('1 avis à donner')
|
||||
expect(page).to have_content("connecté en tant qu’expert")
|
||||
click_on 'Passer en usager'
|
||||
expect(page).to have_current_path(dossiers_path)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue