When there's an out of stock product in the cart, checkout returns user to cart

This commit is contained in:
Rohan Mitchell
2016-03-02 15:23:38 +11:00
parent 9e321a63c0
commit 243f59c87d
2 changed files with 17 additions and 1 deletions

View File

@@ -152,7 +152,7 @@ class CheckoutController < Spree::CheckoutController
# Overriding Spree's methods
def raise_insufficient_quantity
flash[:error] = t(:spree_inventory_error_flash_for_insufficient_quantity)
redirect_to main_app.shop_path
redirect_to cart_path
end
def redirect_to_paypal_express_form_if_needed

View File

@@ -46,6 +46,22 @@ feature "As a consumer I want to check out my cart", js: true do
distributor.shipping_methods << sm3
end
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
it "returns me to the cart with an error message" do
visit checkout_path
page.should_not have_selector 'closing', text: "Checkout now"
page.should have_selector 'closing', text: "Your shopping cart"
page.should have_content "An item in your cart has become unavailable"
end
end
context "on the checkout page" do
before do
visit checkout_path