mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
When there's an out of stock product in the cart, checkout returns user to cart
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user