Merge pull request #11059 from colinux/navbar-procedure-context
ETQ instructeur ou admin je garde le contexte de la démarche en passant d'un profil à l'autre
This commit is contained in:
commit
b426e51d87
15 changed files with 183 additions and 64 deletions
76
spec/components/account_dropdown_component_spec.rb
Normal file
76
spec/components/account_dropdown_component_spec.rb
Normal file
|
@ -0,0 +1,76 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
describe AccountDropdownComponent, type: :component do
|
||||
let(:component) { described_class.new(dossier:, nav_bar_profile:) }
|
||||
let(:dossier) { nil }
|
||||
let(:nav_bar_profile) { :user }
|
||||
let(:user) { build(:user) }
|
||||
|
||||
subject { render_inline(component) }
|
||||
|
||||
before do
|
||||
allow_any_instance_of(ApplicationController).to receive(:current_user).and_return(user)
|
||||
allow_any_instance_of(ApplicationController).to receive(:super_admin_signed_in?).and_return(false)
|
||||
end
|
||||
|
||||
describe 'basic display' do
|
||||
it 'shows user email' do
|
||||
expect(subject).to have_text(user.email)
|
||||
end
|
||||
|
||||
context 'when guest profile' do
|
||||
let(:nav_bar_profile) { :guest }
|
||||
let(:user) { nil }
|
||||
|
||||
it 'does not show profile badge' do
|
||||
expect(subject).not_to have_css('.fr-badge')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'profile switching' do
|
||||
context 'when user profile' do
|
||||
let(:nav_bar_profile) { :user }
|
||||
|
||||
before do
|
||||
allow_any_instance_of(ApplicationController).to receive(:instructeur_signed_in?).and_return(true)
|
||||
end
|
||||
|
||||
it 'shows instructor switch option' do
|
||||
expect(subject).to have_link('Passer en instructeur')
|
||||
expect(subject).not_to have_link('Passer en usager')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when instructor profile' do
|
||||
let(:nav_bar_profile) { :instructeur }
|
||||
|
||||
before do
|
||||
allow_any_instance_of(ApplicationController).to receive(:instructeur_signed_in?).and_return(true)
|
||||
end
|
||||
|
||||
it 'shows user switch option' do
|
||||
expect(subject).to have_link('Passer en usager')
|
||||
expect(subject).not_to have_link('Passer en instructeur')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when in procedures controller' do
|
||||
before do
|
||||
allow_any_instance_of(ApplicationController).to receive(:instructeur_signed_in?).and_return(true)
|
||||
allow_any_instance_of(ApplicationController).to receive(:controller_name).and_return('procedures')
|
||||
end
|
||||
|
||||
context 'with procedure id' do
|
||||
before do
|
||||
allow_any_instance_of(ApplicationController).to receive(:params)
|
||||
.and_return({ id: '123' })
|
||||
end
|
||||
|
||||
it 'links to specific procedure for instructor' do
|
||||
expect(subject.to_html).to include('/procedures/123')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -40,7 +40,7 @@ describe 'Inviting an expert:', js: true do
|
|||
visit new_user_session_path
|
||||
sign_in_with avis.expert.email, password
|
||||
|
||||
expect(page).to have_content('Vous pouvez à tout moment alterner entre vos différents profils : expert, usager.')
|
||||
expect(page).to have_content('Vous pouvez à tout moment alterner entre vos différents profils : expert et usager.')
|
||||
expect(page).to have_current_path(expert_all_avis_path)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -28,7 +28,7 @@ describe 'Signin in:' do
|
|||
|
||||
sign_in_with user.email, password
|
||||
expect(page).to have_current_path admin_procedures_path
|
||||
expect(page).to have_content('Vous êtes connecté(e) ! Vous pouvez à tout moment alterner entre vos différents profils : administrateur, instructeur, usager.')
|
||||
expect(page).to have_content('Vous êtes connecté(e) ! Vous pouvez à tout moment alterner entre vos différents profils : administrateur, instructeur et usager.')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue