From 5f2e72e3d4c28c75ad6d8ca3a949324b2fa8d1f5 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley Date: Wed, 28 Feb 2018 21:24:38 +0000 Subject: [PATCH] Private shop spec --- .../consumer/shopping/shopping_spec.rb | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/spec/features/consumer/shopping/shopping_spec.rb b/spec/features/consumer/shopping/shopping_spec.rb index c226569dfb..4e3dd8781c 100644 --- a/spec/features/consumer/shopping/shopping_spec.rb +++ b/spec/features/consumer/shopping/shopping_spec.rb @@ -430,6 +430,7 @@ feature "As a consumer I want to shop with a distributor", js: true do let(:exchange) { Exchange.find(oc1.exchanges.to_enterprises(distributor).outgoing.first.id) } let(:product) { create(:simple_product) } let(:variant) { create(:variant, product: product) } + let(:unregistered_customer) { create(:customer, user: nil, enterprise: distributor) } before do add_variant_to_order_cycle(exchange, variant) @@ -468,9 +469,7 @@ feature "As a consumer I want to shop with a distributor", js: true do let!(:customer) { create(:customer, user: user, enterprise: distributor) } it "shows just products" do - visit shop_path - expect(page).to have_no_content "This shop is for customers only." - expect(page).to have_content product.name + shows_products_without_customer_warning end end @@ -478,9 +477,7 @@ feature "As a consumer I want to shop with a distributor", js: true do let!(:role) { create(:enterprise_role, user: user, enterprise: distributor) } it "shows just products" do - visit shop_path - expect(page).to have_no_content "This shop is for customers only." - expect(page).to have_content product.name + shows_products_without_customer_warning end end @@ -491,12 +488,28 @@ feature "As a consumer I want to shop with a distributor", js: true do end it "shows just products" do - visit shop_path - expect(page).to have_no_content "This shop is for customers only." - expect(page).to have_content product.name + shows_products_without_customer_warning end end end + + context "when previously unregistered customer registers" do + let!(:returning_user) { create(:user, email: unregistered_customer.email) } + + before do + quick_login_as returning_user + end + + it "shows the products without customer only message" do + shows_products_without_customer_warning + end + end end end + + def shows_products_without_customer_warning + visit shop_path + expect(page).to have_no_content "This shop is for customers only." + expect(page).to have_content product.name + end end