From 99ff7149130dbfbc8cf5cfee52f97c7bc132a910 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Fri, 16 Aug 2019 20:17:14 +0100 Subject: [PATCH] Enable cache on checkout spec to test cache after checkout --- .../consumer/shopping/checkout_spec.rb | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/spec/features/consumer/shopping/checkout_spec.rb b/spec/features/consumer/shopping/checkout_spec.rb index 0733b7df42..a0561c062f 100644 --- a/spec/features/consumer/shopping/checkout_spec.rb +++ b/spec/features/consumer/shopping/checkout_spec.rb @@ -180,8 +180,19 @@ feature "As a consumer I want to check out my cart", js: true do end end - context "in the shopfront" do + context "in the shopfront with cache enabled" do + around do |example| + original_config = Spree::Config[:enable_products_cache?] + example.run + Spree::Config[:enable_products_cache?] = original_config + end + + let(:control_product) { create(:taxed_product, supplier: supplier, price: 110, zone: zone, tax_rate_amount: 0.1) } + let(:control_variant) { control_product.variants.first } + let!(:order_cycle) { create(:simple_order_cycle, suppliers: [supplier], distributors: [distributor], coordinator: create(:distributor_enterprise), variants: [variant, control_variant]) } + it "does not show item after all stock of an item is checked out (tesging cache update on checkout)" do + Spree::Config[:enable_products_cache?] = true variant.update_attributes on_hand: 5 visit shop_path @@ -200,7 +211,10 @@ feature "As a consumer I want to check out my cart", js: true do expect(page).to have_content "Your order has been processed successfully" visit shop_path - page.should_not have_content variant.product.name + # The presence of the control product ensures the list of products is fully loaded + # before we verify the sold product is not present + page.should have_content control_product.name + page.should_not have_content product.name end end