profile_spec.rb 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # Copyright (C) 2012-2022 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. end