From 43a4a3dd5a59bf7d3a77ae986368818e997903bc Mon Sep 17 00:00:00 2001 From: Rob H Date: Thu, 6 Mar 2014 13:14:06 +1100 Subject: [PATCH] Alter on_hand counts for products to fix broken specs --- spec/controllers/cart_controller_spec.rb | 2 +- spec/controllers/spree/orders_controller_spec.rb | 2 +- spec/features/consumer/shopping/shopping_spec.rb | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/controllers/cart_controller_spec.rb b/spec/controllers/cart_controller_spec.rb index 5715b50987..db311a8104 100644 --- a/spec/controllers/cart_controller_spec.rb +++ b/spec/controllers/cart_controller_spec.rb @@ -76,7 +76,7 @@ module OpenFoodNetwork product1.distributors << distributor product1.save - put :add_variant, { cart_id: cart, variant_id: product1.master.id, quantity: 4, distributor_id: distributor, order_cycle_id: nil, max_quantity: nil } + put :add_variant, { cart_id: cart, variant_id: product1.master.id, quantity: (product1.master.on_hand-1), distributor_id: distributor, order_cycle_id: nil, max_quantity: nil } cart.orders.size.should == 1 cart.orders.first.line_items.size.should == 1 diff --git a/spec/controllers/spree/orders_controller_spec.rb b/spec/controllers/spree/orders_controller_spec.rb index 9883914736..322c4a9ef2 100644 --- a/spec/controllers/spree/orders_controller_spec.rb +++ b/spec/controllers/spree/orders_controller_spec.rb @@ -47,7 +47,7 @@ describe Spree::OrdersController do describe "when I pass params that includes a line item no longer in our cart" do it "should silently ignore the missing line item" do order = subject.current_order(true) - li = order.add_variant(create(:simple_product).master) + li = order.add_variant(create(:simple_product, on_hand: 110).master) spree_get :update, order: { line_items_attributes: { "0" => {quantity: "0", id: "9999"}, "1" => {quantity: "99", id: li.id} diff --git a/spec/features/consumer/shopping/shopping_spec.rb b/spec/features/consumer/shopping/shopping_spec.rb index 4476f69571..467ef2365f 100644 --- a/spec/features/consumer/shopping/shopping_spec.rb +++ b/spec/features/consumer/shopping/shopping_spec.rb @@ -236,7 +236,7 @@ feature "As a consumer I want to shop with a distributor", js: true do describe "group buy products" do let(:oc) { create(:simple_order_cycle, distributors: [distributor]) } - let(:product) { create(:simple_product, group_buy: true) } + let(:product) { create(:simple_product, group_buy: true, on_hand: 15) } describe "without variants" do before do @@ -259,7 +259,7 @@ feature "As a consumer I want to shop with a distributor", js: true do end describe "with variants on the product" do - let(:variant) { create(:variant, product: product) } + let(:variant) { create(:variant, product: product, on_hand: 10 ) } before do build_and_select_order_cycle_with_variants find(".expand").trigger "click"