preferences_permission_check_spec.rb 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Profile > PreferencesPermissionCheck', type: :system do
  4. let(:admin) { create(:admin) }
  5. let(:agent) { create(:agent) }
  6. let(:customer) { create(:customer) }
  7. before { visit 'profile' }
  8. shared_examples 'having profile page link to' do |link_name|
  9. it "shows the #{link_name} link" do
  10. within '.content .NavBarProfile' do
  11. expect(page).to have_link(link_name)
  12. end
  13. end
  14. end
  15. shared_examples 'not having profile page link to' do |link_name|
  16. it "does not show the #{link_name} link" do
  17. within '.content .NavBarProfile' do
  18. expect(page).to have_no_link(link_name)
  19. end
  20. end
  21. end
  22. context 'when logged in as admin', authenticated_as: :admin do
  23. it_behaves_like 'having profile page link to', 'Password'
  24. it_behaves_like 'having profile page link to', 'Language'
  25. it_behaves_like 'having profile page link to', 'Linked Accounts'
  26. it_behaves_like 'having profile page link to', 'Avatar'
  27. it_behaves_like 'having profile page link to', 'Notifications'
  28. it_behaves_like 'having profile page link to', 'Out of Office'
  29. it_behaves_like 'having profile page link to', 'Calendar'
  30. it_behaves_like 'having profile page link to', 'Devices'
  31. it_behaves_like 'having profile page link to', 'Token Access'
  32. end
  33. context 'when logged in as agent', authenticated_as: :agent do
  34. it_behaves_like 'having profile page link to', 'Password'
  35. it_behaves_like 'having profile page link to', 'Language'
  36. it_behaves_like 'having profile page link to', 'Linked Accounts'
  37. it_behaves_like 'having profile page link to', 'Avatar'
  38. it_behaves_like 'having profile page link to', 'Notifications'
  39. it_behaves_like 'having profile page link to', 'Out of Office'
  40. it_behaves_like 'having profile page link to', 'Calendar'
  41. it_behaves_like 'having profile page link to', 'Devices'
  42. it_behaves_like 'having profile page link to', 'Token Access'
  43. end
  44. context 'when logged in as customer', authenticated_as: :customer do
  45. it_behaves_like 'having profile page link to', 'Password'
  46. it_behaves_like 'having profile page link to', 'Language'
  47. it_behaves_like 'having profile page link to', 'Linked Accounts'
  48. it_behaves_like 'having profile page link to', 'Avatar'
  49. it_behaves_like 'not having profile page link to', 'Notifications'
  50. it_behaves_like 'not having profile page link to', 'Calendar'
  51. it_behaves_like 'not having profile page link to', 'Token Access'
  52. end
  53. end