From c2f302450f8bb8e3ff90746c58f4696400a6de82 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Fri, 16 Aug 2019 19:35:57 +0100 Subject: [PATCH] Add spec to checkout to validate product is removed from shopfront just after all available quantity is checked out --- .../consumer/shopping/checkout_spec.rb | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/spec/features/consumer/shopping/checkout_spec.rb b/spec/features/consumer/shopping/checkout_spec.rb index a6fc56379c..0733b7df42 100644 --- a/spec/features/consumer/shopping/checkout_spec.rb +++ b/spec/features/consumer/shopping/checkout_spec.rb @@ -180,6 +180,30 @@ feature "As a consumer I want to check out my cart", js: true do end end + context "in the shopfront" do + it "does not show item after all stock of an item is checked out (tesging cache update on checkout)" do + variant.update_attributes on_hand: 5 + visit shop_path + + fill_in "variants[#{variant.id}]", with: '5' + wait_until { !cart_dirty } + + visit checkout_path + checkout_as_guest + + fill_out_details + fill_out_billing_address + choose sm1.name + choose pm1.name + + place_order + expect(page).to have_content "Your order has been processed successfully" + + visit shop_path + page.should_not have_content variant.product.name + end + end + context "on the checkout page" do before do visit checkout_path