Skip to content

Instantly share code, notes, and snippets.

@dball
Created December 2, 2010 22:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dball/726192 to your computer and use it in GitHub Desktop.
Save dball/726192 to your computer and use it in GitHub Desktop.
Factory.define(:passing_inspection_estimate, :parent => :estimate_with_items) do |f|
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 }
location.create_data!(:inspection_failure_id => outcome.id, :created_by => 'factory')
end
end
end
Factory.define(:failing_inspection_estimate, :parent => :estimate_with_items) do |f|
f.after_create do |e|
e.items << Factory(:estimate_item, :estimate => e, :inspection => true, :opcode => Factory(:inspection_op, :dealer => e.dealer).id).tap do |item|
inspection = item.inspections.first
location = inspection.locations.first
outcome = inspection.failures.detect { |outcome| !outcome.performed }
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