2019-06-04 03:40:48 +00:00
|
|
|
FactoryBot.define do
|
|
|
|
factory 'knowledge_base/answer/translation', aliases: %i[knowledge_base_answer_translation] do
|
2019-09-18 17:25:04 +00:00
|
|
|
answer { nil }
|
|
|
|
kb_locale { nil }
|
|
|
|
sequence(:title) { |n| "#{Faker::Appliance.equipment} ##{n}" }
|
|
|
|
content { build(:knowledge_base_answer_translation_content) }
|
|
|
|
|
|
|
|
before(:create) do |translation, _context|
|
|
|
|
if translation.answer.nil?
|
|
|
|
build(:knowledge_base_answer, translations: [translation])
|
|
|
|
end
|
|
|
|
|
|
|
|
if translation.kb_locale.nil?
|
|
|
|
translation.kb_locale = translation.answer.category.knowledge_base.kb_locales.first
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
after(:build) do |translation, _context|
|
|
|
|
if translation.answer.nil?
|
|
|
|
build(:knowledge_base_answer, translations: [translation])
|
|
|
|
end
|
|
|
|
|
|
|
|
if translation.kb_locale.nil?
|
2019-06-04 03:40:48 +00:00
|
|
|
translation.kb_locale = translation.answer.category.knowledge_base.kb_locales.first
|
|
|
|
end
|
|
|
|
end
|
2020-02-19 17:07:52 +00:00
|
|
|
|
|
|
|
trait :with_video do
|
|
|
|
content { build(:knowledge_base_answer_translation_content, :with_video) }
|
|
|
|
end
|
2020-05-28 08:02:07 +00:00
|
|
|
|
|
|
|
trait :with_image do
|
|
|
|
content { build(:knowledge_base_answer_translation_content, :with_image) }
|
|
|
|
end
|
2019-06-04 03:40:48 +00:00
|
|
|
end
|
|
|
|
end
|