You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
567 B
22 lines
567 B
2 years ago
|
FactoryBot.define do
|
||
|
factory :page, class: "Form::Page" do
|
||
|
id { "page_id" }
|
||
|
initialize_with { new(id, nil, nil) }
|
||
|
trait :with_question do
|
||
|
transient do
|
||
|
question_id { nil }
|
||
|
question { nil }
|
||
|
end
|
||
|
|
||
|
after :build do |page, evaluator|
|
||
|
page.questions = if (q = evaluator.question)
|
||
|
q.page = page
|
||
|
[q]
|
||
|
else
|
||
|
[build(:question, id: evaluator.question_id, page:)]
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|