From 01647c3df9dc0e5b47262b7aa820fff7ffe39740 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley Date: Mon, 9 Oct 2017 17:24:29 +0100 Subject: [PATCH] Disable allow_backorders by default in test environment --- spec/controllers/enterprises_controller_spec.rb | 1 - spec/controllers/spree/orders_controller_spec.rb | 1 - spec/features/admin/bulk_order_management_spec.rb | 1 - spec/features/consumer/shopping/cart_spec.rb | 7 ------- spec/features/consumer/shopping/checkout_spec.rb | 2 -- spec/models/spree/order_populator_spec.rb | 6 +----- spec/spec_helper.rb | 2 ++ 7 files changed, 3 insertions(+), 17 deletions(-) diff --git a/spec/controllers/enterprises_controller_spec.rb b/spec/controllers/enterprises_controller_spec.rb index a4e66313dd..baddf49dc9 100644 --- a/spec/controllers/enterprises_controller_spec.rb +++ b/spec/controllers/enterprises_controller_spec.rb @@ -103,7 +103,6 @@ describe EnterprisesController do order.set_distribution! current_distributor, order_cycle order.line_items << line_item - Spree::Config.set allow_backorders: false variant.on_hand = 0 variant.save! end diff --git a/spec/controllers/spree/orders_controller_spec.rb b/spec/controllers/spree/orders_controller_spec.rb index e3a625784c..808a5faa73 100644 --- a/spec/controllers/spree/orders_controller_spec.rb +++ b/spec/controllers/spree/orders_controller_spec.rb @@ -51,7 +51,6 @@ describe Spree::OrdersController do let(:line_item) { order.line_items.last } before do - Spree::Config.allow_backorders = false order.set_distribution! d, oc order.add_variant variant, 5 variant.update_attributes! on_hand: 3 diff --git a/spec/features/admin/bulk_order_management_spec.rb b/spec/features/admin/bulk_order_management_spec.rb index 74c10c7b72..6810c3962e 100644 --- a/spec/features/admin/bulk_order_management_spec.rb +++ b/spec/features/admin/bulk_order_management_spec.rb @@ -109,7 +109,6 @@ feature %q{ let!(:li1) { create(:line_item, order: o1, :quantity => 5 ) } before :each do - Spree::Config.set(allow_backorders: false) li1.variant.update_attributes(on_hand: 1, on_demand: false) visit '/admin/orders/bulk_management' end diff --git a/spec/features/consumer/shopping/cart_spec.rb b/spec/features/consumer/shopping/cart_spec.rb index 5a894db525..000f996b53 100644 --- a/spec/features/consumer/shopping/cart_spec.rb +++ b/spec/features/consumer/shopping/cart_spec.rb @@ -20,13 +20,6 @@ feature "full-page cart", js: true do set_order order end - around do |example| - allow_backorders = Spree::Config.allow_backorders - Spree::Config.allow_backorders = false - example.run - Spree::Config.allow_backorders = allow_backorders - end - describe "product description" do it "does not link to the product page" do add_product_to_cart order, product_fee, quantity: 2 diff --git a/spec/features/consumer/shopping/checkout_spec.rb b/spec/features/consumer/shopping/checkout_spec.rb index 77c79f93a9..1cbf18a32e 100644 --- a/spec/features/consumer/shopping/checkout_spec.rb +++ b/spec/features/consumer/shopping/checkout_spec.rb @@ -47,7 +47,6 @@ feature "As a consumer I want to check out my cart", js: true, retry: 3 do describe "when I have an out of stock product in my cart" do before do - Spree::Config.set allow_backorders: false variant.on_hand = 0 variant.save! end @@ -392,7 +391,6 @@ feature "As a consumer I want to check out my cart", js: true, retry: 3 do end it "takes us to the cart page with an error when a product becomes out of stock just before we purchase", js: true do - Spree::Config.set allow_backorders: false variant.on_hand = 0 variant.save! diff --git a/spec/models/spree/order_populator_spec.rb b/spec/models/spree/order_populator_spec.rb index f0bbc81f55..2b2dd1f3a1 100644 --- a/spec/models/spree/order_populator_spec.rb +++ b/spec/models/spree/order_populator_spec.rb @@ -196,8 +196,6 @@ module Spree let(:v) { double(:variant, on_hand: 10) } context "when backorders are not allowed" do - before { Spree::Config.allow_backorders = false } - context "when max_quantity is not provided" do it "returns full amount when available" do op.quantities_to_add(v, 5, nil).should == [5, nil] @@ -220,10 +218,8 @@ module Spree end context "when backorders are allowed" do - around do |example| + before do Spree::Config.allow_backorders = true - example.run - Spree::Config.allow_backorders = false end it "does not limit quantity" do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 101e0223d3..03e5955a15 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -100,11 +100,13 @@ RSpec.configure do |config| # Ensure we start with consistent config settings config.before(:each) do reset_spree_preferences do |spree_config| + # These are all settings that differ from Spree's defaults spree_config.default_country_id = default_country_id spree_config.checkout_zone = checkout_zone spree_config.currency = currency spree_config.shipping_instructions = true spree_config.auto_capture = true + spree_config.allow_backorders = false end Spree::Api::Config[:requires_authentication] = true