mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-10 23:07:47 +00:00
Add ability to specify variant for order
I will need this in the following commit. For existing specs where no variant is specified, a product with variant will be created (I think this is what the line item factory would have done before).
This commit is contained in:
@@ -141,15 +141,16 @@ FactoryBot.define do
|
||||
factory :order_with_totals_and_distribution, parent: :order_with_distributor do
|
||||
transient do
|
||||
shipping_fee { 3 }
|
||||
product { variant&.product || create(:simple_product) }
|
||||
variant { product.variants.first }
|
||||
end
|
||||
|
||||
order_cycle { create(:simple_order_cycle) }
|
||||
|
||||
after(:create) do |order, proxy|
|
||||
product = create(:simple_product)
|
||||
create(:line_item_with_shipment, shipping_fee: proxy.shipping_fee,
|
||||
order:,
|
||||
product:)
|
||||
variant: proxy.variant)
|
||||
order.reload
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user