menu_item.rb 618 B

1234567891011121314151617181920212223242526
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. FactoryBot.define do
  3. factory 'knowledge_base/menu_item', aliases: %i[knowledge_base_menu_item] do
  4. kb_locale { nil }
  5. sequence(:title) { |n| "menu_#{n}" }
  6. url { Faker::Internet.url }
  7. for_header
  8. before :create do |menu_item|
  9. if menu_item.kb_locale.blank?
  10. kb = create(:knowledge_base)
  11. menu_item.kb_locale = kb.kb_locales.first
  12. end
  13. end
  14. trait :for_footer do
  15. location { 'footer' }
  16. end
  17. trait :for_header do
  18. location { 'header' }
  19. end
  20. end
  21. end