From 9bd6615dadc82bf8e4ccec901c73f8f582810ba1 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Thu, 15 Jun 2023 11:29:26 +1000 Subject: [PATCH] Change spec to "unhide" customers on create --- spec/system/admin/customers_spec.rb | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/spec/system/admin/customers_spec.rb b/spec/system/admin/customers_spec.rb index c9886244fc..3a7a7d8e47 100644 --- a/spec/system/admin/customers_spec.rb +++ b/spec/system/admin/customers_spec.rb @@ -373,26 +373,29 @@ code: nil, created_manually: true) 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 - click_button 'Add Customer' - expect(page).to have_selector "#new-customer-dialog .error", - text: "Email is associated with an existing customer" - }.to change{ customer1.reload.created_manually }.from(false).to(true) - .and change { Customer.of(managed_distributor1).count }.by(0) - # When a new valid email is used expect{ fill_in 'email', with: "new@email.com" click_button 'Add Customer' expect(page).not_to have_selector "#new-customer-dialog" }.to change{ Customer.of(managed_distributor1).count }.from(2).to(3) + end - expect( - Customer.of(managed_distributor1).reorder(:id) - .last.created_manually - ).to be true + it "shows a hidden customer when trying to create it" do + click_link('New Customer') + fill_in 'email', with: customer1.email + + expect do + click_button 'Add Customer' + expect(page).not_to have_selector "#new-customer-dialog" + customer1.reload + end + .to change { customer1.created_manually }.from(false).to(true) + .and change { Customer.count }.by(0) + + expect(page).to have_content customer1.email + expect(page).to have_field "first_name", with: "John" + expect(page).to have_field "last_name", with: "Doe" end end end