From 8236603f76cdbc0053f8dfe465d5445ff93f2cc7 Mon Sep 17 00:00:00 2001 From: David Cook Date: Mon, 5 Jan 2026 15:48:43 +1100 Subject: [PATCH] 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). --- spec/factories/order_factory.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/factories/order_factory.rb b/spec/factories/order_factory.rb index 28abe6dd09..f9c5ecb941 100644 --- a/spec/factories/order_factory.rb +++ b/spec/factories/order_factory.rb @@ -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