feed_spec.rb 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Knowledge Base feed', 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. let(:token) { Token.last }
  12. it 'shows root link at main page' do
  13. visit "#knowledge_base/#{knowledge_base.id}/locale/#{locale_name}"
  14. click '.icon-rss'
  15. in_modal do
  16. link = find('a', text: knowledge_base.translations.first.title)
  17. expect(link[:href]).to end_with feed_knowledge_base_path(knowledge_base, locale_name, token: token.token)
  18. end
  19. end
  20. it 'shows root and category links at category page' do
  21. visit "#knowledge_base/#{knowledge_base.id}/locale/#{locale_name}/category/#{category.id}"
  22. click '.icon-rss'
  23. in_modal do
  24. kb_link = find('a', text: knowledge_base.translations.first.title)
  25. expect(kb_link[:href]).to end_with feed_knowledge_base_path(knowledge_base, locale_name, token: token.token)
  26. category_link = find('a', text: category.translations.first.title)
  27. expect(category_link[:href]).to end_with feed_knowledge_base_category_path(knowledge_base, category, locale_name, token: token.token)
  28. end
  29. end
  30. it 'shows root and category links at answer page' do
  31. visit "#knowledge_base/#{knowledge_base.id}/locale/#{locale_name}/answer/#{published_answer.id}"
  32. click '.icon-rss'
  33. in_modal do
  34. kb_link = find('a', text: knowledge_base.translations.first.title)
  35. expect(kb_link[:href]).to end_with feed_knowledge_base_path(knowledge_base, locale_name, token: token.token)
  36. category_link = find('a', text: category.translations.first.title)
  37. expect(category_link[:href]).to end_with feed_knowledge_base_category_path(knowledge_base, category, locale_name, token: token.token)
  38. end
  39. end
  40. end
  41. context 'when feed is off' do
  42. let(:show_feed_icon) { false }
  43. it 'does not show icon' do
  44. visit "#knowledge_base/#{knowledge_base.id}/locale/#{locale_name}"
  45. expect(page).to have_no_css('.icon-rss')
  46. end
  47. end
  48. end