knowledge_base_contexts.rb 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # Copyright (C) 2012-2023 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 :other_category do
  19. create(:knowledge_base_category, knowledge_base: knowledge_base)
  20. end
  21. let :draft_answer do
  22. create(:knowledge_base_answer, category: category)
  23. end
  24. let :published_answer do
  25. create(:knowledge_base_answer, :published, :with_attachment, category: category)
  26. end
  27. let :published_answer_in_other_category do
  28. create(:knowledge_base_answer, :published, category: other_category)
  29. end
  30. let :published_answer_with_video do
  31. create(:knowledge_base_answer, :published, :with_video, category: category)
  32. end
  33. let :published_answer_with_image do
  34. create(:knowledge_base_answer, :published, :with_image, category: category)
  35. end
  36. let :published_answer_with_tag do
  37. create(:knowledge_base_answer, :published, :with_tag, tag_names: [published_answer_tag_name], category: category)
  38. end
  39. let(:published_answer_tag_name) do
  40. 'example_kb_tag'
  41. end
  42. let :internal_answer do
  43. create(:knowledge_base_answer, :internal, category: category)
  44. end
  45. let :archived_answer do
  46. create(:knowledge_base_answer, :archived, category: category)
  47. end
  48. end
  49. RSpec.shared_context 'Knowledge Base menu items', current_user_id: 1 do # rubocop:disable RSpec/ContextWording
  50. # rubocop:disable RSpec/LetSetup
  51. let!(:menu_item_1) { create(:knowledge_base_menu_item, :for_header, kb_locale: primary_locale) }
  52. let!(:menu_item_2) { create(:knowledge_base_menu_item, :for_header, kb_locale: primary_locale) }
  53. let!(:menu_item_3) { create(:knowledge_base_menu_item, :for_footer, kb_locale: primary_locale) }
  54. let!(:menu_item_4) { create(:knowledge_base_menu_item, :for_footer, kb_locale: alternative_locale) }
  55. let!(:menu_item_5) { create(:knowledge_base_menu_item, :for_footer, kb_locale: alternative_locale) }
  56. # rubocop:enable RSpec/LetSetup
  57. end