From 79ff13e8ba866ce651ae29d16f212ecdc1cfd185 Mon Sep 17 00:00:00 2001 From: paulo-felipe Date: Thu, 11 May 2023 20:31:43 -0300 Subject: [PATCH] refactor(spec/system/admin/subscriptions_spec.rb): issue #7483 Move on second page to a before action and clearing some elements of bill address to a before action. Let the unit test with the action isolated. --- spec/system/admin/subscriptions_spec.rb | 28 ++++++++++++++++--------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/spec/system/admin/subscriptions_spec.rb b/spec/system/admin/subscriptions_spec.rb index 41d564045c..40ab1c3b20 100644 --- a/spec/system/admin/subscriptions_spec.rb +++ b/spec/system/admin/subscriptions_spec.rb @@ -270,7 +270,7 @@ describe 'Subscriptions' do end context 'on second page' do - it 'counts 6 can not be blank messages' do + before do select2_select customer.email, from: 'customer_id' select2_select schedule.name, from: 'schedule_id' select2_select payment_method.name, from: 'payment_method_id' @@ -278,15 +278,23 @@ describe 'Subscriptions' do find_field('begins_at').click choose_today_from_datepicker click_button('Next') - # Clear some elements of bill address - fill_in "bill_address_firstname", with: '' - fill_in "bill_address_lastname", with: '' - fill_in "bill_address_address1", with: '' - fill_in "bill_address_city", with: '' - fill_in "bill_address_zipcode", with: '' - fill_in "bill_address_phone", with: '' - click_button('Next') - expect(page).to have_content 'can\'t be blank', count: 6 + end + + context 'when clearing some elements of bill address' do + before do + # Clear some elements of bill address + fill_in "bill_address_firstname", with: '' + fill_in "bill_address_lastname", with: '' + fill_in "bill_address_address1", with: '' + fill_in "bill_address_city", with: '' + fill_in "bill_address_zipcode", with: '' + fill_in "bill_address_phone", with: '' + end + + it 'counts 6 can not be blank messages' do + click_button('Next') + expect(page).to have_content 'can\'t be blank', count: 6 + end end end