profile_spec.rb 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Profile', type: :system do
  4. it 'shows profile link in navigation' do
  5. visit 'dashboard'
  6. find('a[href="#current_user"]').click
  7. expect(page).to have_css('.dropdown-menu > li > a[href="#profile"]')
  8. end
  9. context 'when user is an agent with no user_preferences permission', authenticated_as: :new_user do
  10. let(:role) { create(:role, permissions: [Permission.find_by(name: 'ticket.agent')]) }
  11. let(:new_user) { create(:user, roles: [role]) }
  12. it 'does not show profile link in navigation' do
  13. visit 'dashboard'
  14. find('a[href="#current_user"]').click
  15. expect(page).to have_no_css('.dropdown-menu > li > a[href="#profile"]')
  16. end
  17. end
  18. context "Don't provide option to create API-Token if authentication via API token is disabled #3168" do
  19. before do
  20. visit 'profile'
  21. end
  22. it 'does show the navbar link Token Access based on the Setting api_token_access' do
  23. expect(page).to have_text('Token Access')
  24. # disable token access
  25. visit 'system/api'
  26. click 'label[for=api_token_access]'
  27. visit 'profile'
  28. expect(page).to have_no_text('Token Access')
  29. # enable token access
  30. visit 'system/api'
  31. click 'label[for=api_token_access]'
  32. visit 'profile'
  33. expect(page).to have_text('Token Access')
  34. end
  35. end
  36. context 'when password login is disabled', authenticated_as: :authenticate do
  37. let(:user) { create(:agent) }
  38. def authenticate
  39. Setting.set('user_show_password_login', false)
  40. user
  41. end
  42. before do
  43. visit 'profile'
  44. end
  45. it 'does not show password profile' do
  46. expect(page).to have_no_text('Password')
  47. end
  48. context 'with admin user' do
  49. let(:user) { create(:admin) }
  50. it 'does show password profile' do
  51. expect(page).to have_text('Password')
  52. end
  53. end
  54. end
  55. end