feed_spec.rb 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Public Knowledge Base feed', authenticated_as: false, type: :system do
  4. include_context 'basic Knowledge Base'
  5. before do
  6. knowledge_base.update! show_feed_icon: show_feed_icon
  7. published_answer
  8. end
  9. context 'when feed is on' do
  10. let(:show_feed_icon) { true }
  11. it 'shows root link at main page' do
  12. visit help_root_path(locale_name)
  13. click '.icon-rss'
  14. within '.dropdown-menu' do
  15. link = find('a', text: knowledge_base.translations.first.title)
  16. expect(link[:href]).to end_with help_root_feed_path(locale_name)
  17. end
  18. end
  19. it 'shows root and category links at category page' do
  20. visit help_category_path(locale_name, category)
  21. click '.icon-rss'
  22. within '.dropdown-menu' do
  23. kb_link = find('a', text: knowledge_base.translations.first.title)
  24. expect(kb_link[:href]).to end_with help_root_feed_path(locale_name)
  25. category_link = find('a', text: category.translations.first.title)
  26. expect(category_link[:href]).to end_with help_category_feed_path(locale_name, category)
  27. end
  28. end
  29. it 'shows root and category links at answer page' do
  30. visit help_answer_path(locale_name, category, published_answer)
  31. click '.icon-rss'
  32. within '.dropdown-menu' do
  33. kb_link = find('a', text: knowledge_base.translations.first.title)
  34. expect(kb_link[:href]).to end_with help_root_feed_path(locale_name)
  35. category_link = find('a', text: category.translations.first.title)
  36. expect(category_link[:href]).to end_with help_category_feed_path(locale_name, category)
  37. end
  38. end
  39. end
  40. context 'when feed is off' do
  41. let(:show_feed_icon) { false }
  42. it 'does not show icon' do
  43. visit help_root_path(locale_name)
  44. expect(page).to have_no_css('.icon-rss')
  45. end
  46. end
  47. end