Skip to content

Instantly share code, notes, and snippets.

@tadiou
Created May 2, 2016 16:00
Show Gist options
  • Save tadiou/3f56edb32a4f32745cbbeffcc2160008 to your computer and use it in GitHub Desktop.
Save tadiou/3f56edb32a4f32745cbbeffcc2160008 to your computer and use it in GitHub Desktop.
# == Schema Information
#
# Table name: act_passages
#
# id :integer not null, primary key
# title :string not null
# content :text not null
# passage_type_id :integer
# science_section :integer
# section_id :integer
# crm_id :string not null
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_act_passages_on_passage_type_id (passage_type_id)
# index_act_passages_on_section_id (section_id)
#
FactoryGirl.define do
factory :act_passage, class: 'Act::Passage' do
title { Faker::Book.title }
content { Faker::Hipster.paragraph(2) }
crm_id { Faker::Number.hexadecimal(8) }
association :passage_type, factory: :act_passage_type
association :section, factory: :act_section
# This doesn't work, but I'd like to find out why.
# trait :with_questions do
# transient do
# number_of_questions 15
# # not entirely sure why this requires an actual entity vs a FG entity
# # it's rather strange here. EITHER WAY.
# question_section nil
# end
# after(:create) do |passage, evaluator|
# evaluator.question_section ||= create(:act_section)
# create_list(:act_question,
# evaluator.number_of_questions,
# section_id: evaluator.question_section.id,
# passage: passage)
# end
# end
end
end
@tadiou
Copy link
Author

tadiou commented May 2, 2016

This doesn't work. I'm not sure why.

question_section nil fails, you can't pass a section object to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment