mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Change add_product_to_cart spec helper to use OrderPopulator, reducing inconsistencies in order adjustments, tax etc.
This commit is contained in:
@@ -9,7 +9,7 @@ feature "As a consumer I want to check out my cart", js: true do
|
||||
|
||||
let(:distributor) { create(:distributor_enterprise, with_payment_and_shipping: true) }
|
||||
let(:supplier) { create(:supplier_enterprise) }
|
||||
let!(:order_cycle) { create(:simple_order_cycle, distributors: [distributor], coordinator: create(:distributor_enterprise)) }
|
||||
let!(:order_cycle) { create(:simple_order_cycle, distributors: [distributor], coordinator: create(:distributor_enterprise), variants: [product.master]) }
|
||||
let(:product) { create(:simple_product, supplier: supplier) }
|
||||
let(:order) { create(:order, order_cycle: order_cycle, distributor: distributor) }
|
||||
let(:address) { create(:address, firstname: "Foo", lastname: "Bar") }
|
||||
|
||||
@@ -12,7 +12,7 @@ feature "As a consumer I want to check out my cart", js: true do
|
||||
let(:supplier) { create(:supplier_enterprise) }
|
||||
let!(:order_cycle) { create(:simple_order_cycle, suppliers: [supplier], distributors: [distributor], coordinator: create(:distributor_enterprise), variants: [product.master]) }
|
||||
let(:enterprise_fee) { create(:enterprise_fee, amount: 1.23) }
|
||||
let(:product) { create(:simple_product, supplier: supplier) }
|
||||
let(:product) { create(:simple_product, supplier: supplier, price: 10) }
|
||||
let(:order) { create(:order, order_cycle: order_cycle, distributor: distributor) }
|
||||
|
||||
before do
|
||||
|
||||
@@ -17,11 +17,10 @@ module ShopWorkflow
|
||||
end
|
||||
|
||||
def add_product_to_cart
|
||||
create(:line_item, variant: product.master, order: order)
|
||||
order.reload
|
||||
populator = Spree::OrderPopulator.new(order, order.currency)
|
||||
populator.populate(variants: {product.master.id => 1})
|
||||
|
||||
# Recalculate totals
|
||||
order.save!
|
||||
# Recalculate fee totals
|
||||
order.update_distribution_charge!
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user