public_link_spec.rb 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Login > Public Links', authenticated_as: false, type: :system do
  4. context 'with showing public links' do
  5. let(:links) do
  6. first_link = create(:public_link, title: 'Zammad Community', link: 'https://zammad.org')
  7. second_link = create(:public_link, title: 'Zammad Company', link: 'https://zammad.com')
  8. {
  9. first: first_link,
  10. second: second_link,
  11. }
  12. end
  13. shared_examples 'displays public links in footer' do
  14. it 'shows public links in footer' do
  15. expect(page).to have_link('Zammad Community', href: 'https://zammad.org')
  16. expect(page).to have_link('Zammad Company', href: 'https://zammad.com')
  17. end
  18. end
  19. context 'with enabled user_create_account setting' do
  20. before do
  21. links
  22. setup(user_create_account: true)
  23. end
  24. include_examples 'displays public links in footer'
  25. end
  26. context 'with disabled user_create_account setting' do
  27. before do
  28. links
  29. setup(user_create_account: false)
  30. end
  31. include_examples 'displays public links in footer'
  32. end
  33. context 'with no public links' do
  34. before do
  35. visit_login
  36. end
  37. it 'does not show public links in footer' do
  38. link_tags = find_all(:xpath, '//a[@href="#signup"]//../a')
  39. expect(link_tags.size).to eq(1)
  40. end
  41. end
  42. end
  43. def setup(user_create_account:)
  44. Setting.set('user_create_account', user_create_account)
  45. visit_login
  46. end
  47. def visit_login
  48. visit '/'
  49. ensure_websocket
  50. end
  51. end