knowledge_base_contexts.rb 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
  2. RSpec.shared_context 'basic Knowledge Base', current_user_id: 1 do # rubocop:disable RSpec/ContextWording
  3. let :knowledge_base do
  4. create(:knowledge_base)
  5. end
  6. let :primary_locale do
  7. knowledge_base.translation_primary.kb_locale
  8. end
  9. let :locale_name do
  10. primary_locale.system_locale.locale
  11. end
  12. let :alternative_locale do
  13. create(:knowledge_base_locale, knowledge_base: knowledge_base, system_locale: Locale.find_by(locale: 'lt'))
  14. end
  15. let :category do
  16. create(:knowledge_base_category, knowledge_base: knowledge_base)
  17. end
  18. let :draft_answer do
  19. create(:knowledge_base_answer, category: category)
  20. end
  21. let :published_answer do
  22. create(:knowledge_base_answer, :published, :with_attachment, category: category)
  23. end
  24. let :published_answer_with_video do
  25. create(:knowledge_base_answer, :published, :with_video, category: category)
  26. end
  27. let :published_answer_with_tag do
  28. create(:knowledge_base_answer, :published, :with_tag, tag_names: [published_answer_tag_name], category: category)
  29. end
  30. let(:published_answer_tag_name) do
  31. 'example_kb_tag'
  32. end
  33. let :internal_answer do
  34. create(:knowledge_base_answer, :internal, category: category)
  35. end
  36. let :archived_answer do
  37. create(:knowledge_base_answer, :archived, category: category)
  38. end
  39. end
  40. RSpec.shared_context 'Knowledge Base menu items', current_user_id: 1 do # rubocop:disable RSpec/ContextWording
  41. # rubocop:disable RSpec/LetSetup
  42. let!(:menu_item_1) { create(:knowledge_base_menu_item, :for_header, kb_locale: primary_locale) }
  43. let!(:menu_item_2) { create(:knowledge_base_menu_item, :for_header, kb_locale: primary_locale) }
  44. let!(:menu_item_3) { create(:knowledge_base_menu_item, :for_footer, kb_locale: primary_locale) }
  45. let!(:menu_item_4) { create(:knowledge_base_menu_item, :for_footer, kb_locale: alternative_locale) }
  46. let!(:menu_item_5) { create(:knowledge_base_menu_item, :for_footer, kb_locale: alternative_locale) }
  47. # rubocop:enable RSpec/LetSetup
  48. end