Change add_product_to_cart spec helper to use OrderPopulator, reducing inconsistencies in order adjustments, tax etc.

This commit is contained in:
Rohan Mitchell
2015-04-02 11:23:04 +11:00
parent 210c76eddc
commit 68f0e51c02
3 changed files with 5 additions and 6 deletions

View File

@@ -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") }

View File

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

View File

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