From 68f0e51c028df88a61485adb4be72d87da022007 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Thu, 2 Apr 2015 11:23:04 +1100 Subject: [PATCH] Change add_product_to_cart spec helper to use OrderPopulator, reducing inconsistencies in order adjustments, tax etc. --- spec/features/consumer/shopping/checkout_auth_spec.rb | 2 +- spec/features/consumer/shopping/checkout_spec.rb | 2 +- spec/support/request/shop_workflow.rb | 7 +++---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/spec/features/consumer/shopping/checkout_auth_spec.rb b/spec/features/consumer/shopping/checkout_auth_spec.rb index aaf543a7fa..8b4f3bb977 100644 --- a/spec/features/consumer/shopping/checkout_auth_spec.rb +++ b/spec/features/consumer/shopping/checkout_auth_spec.rb @@ -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") } diff --git a/spec/features/consumer/shopping/checkout_spec.rb b/spec/features/consumer/shopping/checkout_spec.rb index 290335f09e..a17f7910ec 100644 --- a/spec/features/consumer/shopping/checkout_spec.rb +++ b/spec/features/consumer/shopping/checkout_spec.rb @@ -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 diff --git a/spec/support/request/shop_workflow.rb b/spec/support/request/shop_workflow.rb index 8f088095e8..a0e6ab846c 100644 --- a/spec/support/request/shop_workflow.rb +++ b/spec/support/request/shop_workflow.rb @@ -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