feed_spec.rb 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'KnowledgeBase public feed', type: :request do
  4. include_context 'basic Knowledge Base'
  5. before do
  6. published_answer
  7. travel 1.minute
  8. published_answer_in_other_category
  9. end
  10. describe '#root' do
  11. before do
  12. get help_root_feed_path(locale_name)
  13. end
  14. it 'lists entries' do
  15. answer_index = response.body.index published_answer.translations.first.title
  16. answer_index2 = response.body.index published_answer_in_other_category.translations.first.title
  17. expect(answer_index > answer_index2).to be_truthy
  18. end
  19. it 'uses KB title' do
  20. expect(response.body).to include(knowledge_base.translations.first.title)
  21. end
  22. end
  23. describe '#category' do
  24. before do
  25. get help_category_feed_path(locale_name, category)
  26. end
  27. it 'lists entries', :aggregate_failures do
  28. expect(response.body).to include(published_answer.translations.first.title)
  29. expect(response.body).not_to include(published_answer_in_other_category.translations.first.title)
  30. end
  31. it 'uses category title' do
  32. expect(response.body).to include(category.translations.first.title)
  33. end
  34. end
  35. context 'with no answers' do
  36. before do
  37. Ticket.destroy_all
  38. end
  39. it 'loads' do
  40. get help_root_feed_path(locale_name)
  41. expect(response).to have_http_status :ok
  42. end
  43. end
  44. end