Fixes #3546 - Dont display profile link if user has no user_preferences.* permissions at all

This commit is contained in:
Romit Choudhary 2021-05-17 15:09:58 +00:00 committed by Thorsten Eckel
parent 992aa6d837
commit 17f457cb58
2 changed files with 24 additions and 1 deletions

View file

@ -23,4 +23,4 @@ App.Config.set('profile', ProfileRouter, 'Routes')
App.Config.set('profile/:target', ProfileRouter, 'Routes') App.Config.set('profile/:target', ProfileRouter, 'Routes')
App.Config.set('Profile', { prio: 1000, name: 'Profile', target: '#profile' }, 'NavBarProfile') App.Config.set('Profile', { prio: 1000, name: 'Profile', target: '#profile' }, 'NavBarProfile')
App.Config.set('Profile', { prio: 1700, parent: '#current_user', name: 'Profile', target: '#profile', translate: true }, 'NavBarRight') App.Config.set('Profile', { prio: 1700, parent: '#current_user', name: 'Profile', target: '#profile', permission: ['user_preferences.*'], translate: true }, 'NavBarRight')

View file

@ -0,0 +1,23 @@
require 'rails_helper'
RSpec.describe 'Profile', type: :system do
it 'shows profile link in navigation' do
visit 'dashboard'
find('a[href="#current_user"]').click
expect(page).to have_css('.dropdown-menu > li > a[href="#profile"]')
end
context 'when user is an agent with no user_preferences permission', authenticated_as: :new_user do
let(:role) { create(:role, permissions: [Permission.find_by(name: 'ticket.agent')]) }
let(:new_user) { create(:user, roles: [role] ) }
it 'does not show profile link in navigation' do
visit 'dashboard'
find('a[href="#current_user"]').click
expect(page).to have_no_css('.dropdown-menu > li > a[href="#profile"]')
end
end
end