2019-06-04 03:40:48 +00:00
|
|
|
FactoryBot.define do
|
|
|
|
factory 'knowledge_base/answer', aliases: %i[knowledge_base_answer] do
|
2019-09-24 13:04:42 +00:00
|
|
|
transient do
|
|
|
|
add_translation { true }
|
2020-02-19 17:07:52 +00:00
|
|
|
translation_traits { [] }
|
2019-09-24 13:04:42 +00:00
|
|
|
end
|
|
|
|
|
2019-06-04 03:40:48 +00:00
|
|
|
category { create(:knowledge_base_category) }
|
2019-09-18 17:25:04 +00:00
|
|
|
|
2020-02-19 17:07:52 +00:00
|
|
|
before(:create) do |answer, context|
|
2019-09-18 17:25:04 +00:00
|
|
|
next if answer.translations.present?
|
|
|
|
|
2020-02-19 17:07:52 +00:00
|
|
|
answer.translations << build('knowledge_base/answer/translation', *context.translation_traits, answer: answer)
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :with_video do
|
|
|
|
transient do
|
|
|
|
translation_traits { [:with_video] }
|
|
|
|
end
|
2019-09-18 17:25:04 +00:00
|
|
|
end
|
2019-06-04 03:40:48 +00:00
|
|
|
end
|
|
|
|
end
|