From 0e85811cabadccfdb21ab44c9eb78432a34f498b Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Mon, 19 Jul 2021 17:55:19 +0100 Subject: [PATCH] Adds test for valid_email2 email validation --- spec/features/admin/customers_spec.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/spec/features/admin/customers_spec.rb b/spec/features/admin/customers_spec.rb index b42032be77..9b686e9e13 100644 --- a/spec/features/admin/customers_spec.rb +++ b/spec/features/admin/customers_spec.rb @@ -343,15 +343,23 @@ feature 'Customers' do end it "creates customers when the email provided is valid" do - # When an invalid email is used + # When an invalid email without domain is used it is checked by a regex, in the UI expect{ click_link('New Customer') - fill_in 'email', with: "not_an_email" + fill_in 'email', with: "email_with_no_domain@" click_button 'Add Customer' expect(page).to have_selector "#new-customer-dialog .error", text: "Please enter a valid email address" }.to_not change{ Customer.of(managed_distributor1).count } + # When an invalid email with domain is used it is checked by the "valid_email2" gem #7886 + expect{ + fill_in 'email', with: "invalid_email_with_no_complete_domain@incomplete" + click_button 'Add Customer' + expect(page).to have_selector "#new-customer-dialog .error", + text: "Email is invalid" + }.to_not change{ Customer.of(managed_distributor1).count } + # When an existing email is used expect{ fill_in 'email', with: customer1.email