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
This commit is contained in:
Jean-Baptiste Bellet
2022-10-13 16:04:28 +02:00
parent d797ef2b3a
commit edb2645af1
3 changed files with 19 additions and 3 deletions

View File

@@ -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.

View File

@@ -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

View File

@@ -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"