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.
21 lines
694 B
21 lines
694 B
1 year ago
|
FactoryBot.define do
|
||
|
factory :subsection, class: "Form::Subsection" do
|
||
|
id { "subsection_id" }
|
||
|
initialize_with { new(id, nil, nil) }
|
||
|
trait :with_questions do
|
||
|
transient do
|
||
|
question_ids { nil }
|
||
|
questions { nil }
|
||
|
end
|
||
|
|
||
|
after :build do |subsection, evaluator|
|
||
|
subsection.pages = if evaluator.questions
|
||
|
evaluator.questions.map { |question| build(:page, :with_question, question:, subsection:) }
|
||
|
else
|
||
|
evaluator.question_ids.map { |question_id| build(:page, :with_question, question_id:, subsection:) }
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|