Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Return only countries with states

Damian Legawieca34b1a6bf264
diff --git a/backend/app/controllers/spree/admin/states_controller.rb b/backend/app/controllers/spree/admin/states_controller.rb
index 9e0d376774..eb56588a55 100644
--- a/backend/app/controllers/spree/admin/states_controller.rb
+++ b/backend/app/controllers/spree/admin/states_controller.rb
@@ -22,7 +22,7 @@ module Spree
end
def load_data
- @countries = Country.order(:name)
+ @countries = Spree::Country.where(states_required: true).order(:name)
end
end
end
diff --git a/backend/spec/features/admin/configuration/states_spec.rb b/backend/spec/features/admin/configuration/states_spec.rb
index f8281b1bc5..6f433dac2f 100755
--- a/backend/spec/features/admin/configuration/states_spec.rb
+++ b/backend/spec/features/admin/configuration/states_spec.rb
@@ -3,10 +3,10 @@ require 'spec_helper'
describe 'States', type: :feature do
stub_authorization!
- let!(:country) { create(:country) }
+ let!(:country) { create(:country, states_required: true) }
before do
- @hungary = Spree::Country.create!(name: 'Hungary', iso_name: 'Hungary', iso: 'HU', iso3: 'HUN')
+ @hungary = Spree::Country.create!(name: 'Hungary', iso_name: 'Hungary', iso: 'HU', iso3: 'HUN', states_required: true)
end
def go_to_states_page
@@ -24,8 +24,8 @@ describe 'States', type: :feature do
end
end
- context 'creating and editing states' do
- it 'allows an admin to edit existing states', js: true do
+ context 'creating and editing states', js: true do
+ it 'allows an admin to edit existing states' do
go_to_states_page
choose_country(country.name)
@@ -37,7 +37,7 @@ describe 'States', type: :feature do
expect(page).to have_content('Calgary')
end
- it 'allows an admin to create states for non default countries', js: true do
+ it 'allows an admin to create states for non default countries' do
go_to_states_page
choose_country(@hungary.name)
@@ -50,7 +50,7 @@ describe 'States', type: :feature do
expect(page).to have_css('.form-group[data-hook="country"]', text: 'Hungary')
end
- it 'shows validation errors', js: true do
+ it 'shows validation errors' do
go_to_states_page
choose_country(country.name)