foodsoft/spec/factories/order.rb

28 lines
669 B
Ruby
Raw Normal View History

2013-07-15 00:17:07 +02:00
require 'factory_girl'
FactoryGirl.define do
factory :order do
starts { Time.now }
2013-07-25 11:16:39 +02:00
supplier { FactoryGirl.create :supplier, article_count: (article_count.nil? ? true : article_count) }
article_ids { supplier.articles.map(&:id) unless supplier.nil? }
2013-07-15 00:17:07 +02:00
2013-07-25 11:16:39 +02:00
ignore do
article_count true
end
# for an order from stock; need to add articles
2013-07-15 00:17:07 +02:00
factory :stock_order do
supplier_id 0
2013-07-25 11:16:39 +02:00
# article_ids needs to be supplied
end
# In the order's after_save callback order articles are created, so
# until the order is saved, these articles do not yet exist.
after :create do |order|
order.reload
2013-07-15 00:17:07 +02:00
end
end
end