From edb2645af1445bf0a7480363ad859e595d4b403f Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Thu, 13 Oct 2022 16:04:28 +0200 Subject: [PATCH] Add a country to test db and modify one spec Check that businness address changes are ok Test with another county since only one country and one state couldn't spot the fact that when changing country it needs to change also states selector --- spec/support/seeds.rb | 8 ++++++++ .../admin/enterprises/business_address_form_spec.rb | 12 ++++++++++-- spec/system/consumer/registration_spec.rb | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/spec/support/seeds.rb b/spec/support/seeds.rb index 8321705e3d..dc75402bcb 100644 --- a/spec/support/seeds.rb +++ b/spec/support/seeds.rb @@ -15,6 +15,14 @@ if Spree::Country.where(name: "Australia").empty? Spree::State.create!({ "name" => "New South Wales", "abbr" => "NSW", :country => country }) end +if Spree::Country.where(name: "France").empty? + Spree::Country.create!({ "name" => "France", "iso3" => "FRA", "iso" => "FR", + "iso_name" => "FRANCE", "numcode" => "250" }) + country = Spree::Country.find_by(name: 'France') + Spree::State.create!({ "name" => "Alsace", "abbr" => "Als", :country => country }) + Spree::State.create!({ "name" => "Aquitaine", "abbr" => "Aq", :country => country }) +end + # Since the country seeding differs from other environments, the default # country id has to be updated here. This line can be removed as soon as the # default country id is replaced by something database independent. diff --git a/spec/system/admin/enterprises/business_address_form_spec.rb b/spec/system/admin/enterprises/business_address_form_spec.rb index bbf63b04dd..17c071366b 100644 --- a/spec/system/admin/enterprises/business_address_form_spec.rb +++ b/spec/system/admin/enterprises/business_address_form_spec.rb @@ -33,12 +33,20 @@ describe "Business Address" do fill_in 'enterprise_business_address_attributes_address1', with: '35 Ballantyne St' fill_in 'enterprise_business_address_attributes_city', with: 'Thornbury' fill_in 'enterprise_business_address_attributes_zipcode', with: '3072' - select 'Australia', from: 'enterprise_business_address_attributes_country_id' - select 'Victoria', from: 'enterprise_business_address_attributes_state_id' + select 'France', from: 'enterprise_business_address_attributes_country_id' + select 'Aquitaine', from: 'enterprise_business_address_attributes_state_id' fill_in 'enterprise_business_address_attributes_phone', with: '0123456789' click_button "Update" expect(page).to have_content("Enterprise \"First Distributor\" has been successfully updated!") + + click_link "Business Details" + expect(page).to have_content "France" + expect(page).to have_content "Aquitaine" + distributor.reload + expect(distributor.business_address).to be_present + expect(distributor.business_address.country).to eq Spree::Country.find_by(name: 'France') + expect(distributor.business_address.state).to eq Spree::State.find_by(name: 'Aquitaine') end it 'is missing company field' do diff --git a/spec/system/consumer/registration_spec.rb b/spec/system/consumer/registration_spec.rb index 5609430a2e..1ccb014ce2 100644 --- a/spec/system/consumer/registration_spec.rb +++ b/spec/system/consumer/registration_spec.rb @@ -56,7 +56,7 @@ describe "Registration", js: true do fill_in 'enterprise_address', with: '123 Abc Street' fill_in 'enterprise_city', with: 'Northcote' fill_in 'enterprise_zipcode', with: '3070' - expect(page).to have_select('enterprise_country', options: ["Albania", "Australia"], + expect(page).to have_select('enterprise_country', options: ["Albania", "Australia", "France"], selected: 'Australia') select 'Vic', from: 'enterprise_state' click_button "Continue"