Skip to content

Instantly share code, notes, and snippets.

@jferris
Forked from dball/gist:726192
Created December 2, 2010 22:22
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 jferris/726204 to your computer and use it in GitHub Desktop.
Save jferris/726204 to your computer and use it in GitHub Desktop.
Factory.define(:estimate_with_items) do |f|
# ...
f.passing(true).ignore
f.after_create do |e|
e.items << Factory(:estimate_item, :estimate => e, :inspection => true, :op => Factory(:inspection_op, :dealer => e.dealer)).tap do |item|
inspection = item.inspections.first
location = inspection.locations.first
outcome = inspection.failures.detect { |outcome| outcome.performed == passing }
location.create_data!(:inspection_failure_id => outcome.id, :created_by => 'factory')
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment