Skip to content

Instantly share code, notes, and snippets.

@johnbayne
Created February 7, 2013 18:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnbayne/4732950 to your computer and use it in GitHub Desktop.
Save johnbayne/4732950 to your computer and use it in GitHub Desktop.
factory :project do
sequence(:name) { |n| "Test Factory #{n}" }
# I'd prefer to do something like this, with 'active' set to true
# steps { |s| [s.association(:step)] }
active false
association :project_group
project_type 'Delivery'
delimiter ';'
ignore { question_count 2 }
after(:create) do |project, evaluator|
create_list(:textfield_question, evaluator.question_count, project: project)
# Instead of this, which is clumsy & requires an extra hit to the database
project.steps << FactoryGirl.create(:step, project: project)
project.active = true
project.save!
end
end
FactoryGirl.define do
factory :step do
sequence(:name) { |n| "Test Step #{n}" }
sequence(:ordinal) { |n| n }
gold_threshold 10
association :project
gold_size_in_burst 5
prod_size_in_burst 5
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment