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:
David Cook
2026-01-05 15:48:43 +11:00
parent c0bcf177e7
commit 8236603f76

View File

@@ -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