knowledge_base.rb 606 B

1234567891011121314151617181920212223
  1. FactoryBot.define do
  2. factory :knowledge_base do
  3. transient do
  4. given_kb_locale { nil }
  5. end
  6. iconset { 'FontAwesome' }
  7. color_highlight { '#AAA' }
  8. color_header { '#EEE' }
  9. homepage_layout { 'grid' }
  10. category_layout { 'list' }
  11. before :create do |kb, context|
  12. if context.given_kb_locale.present?
  13. kb.kb_locales << context.given_kb_locale
  14. context.given_kb_locale.knowledge_base = kb
  15. end
  16. if kb.kb_locales.blank?
  17. kb.kb_locales << build(:knowledge_base_locale, knowledge_base: kb, primary: true)
  18. end
  19. end
  20. end
  21. end