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.

Fixed display of available countries on checkout

Nathaniel Nande90df4f16e182
diff --git a/core/app/helpers/spree/base_helper.rb b/core/app/helpers/spree/base_helper.rb
index 780a6872d6..4cca35fe23 100644
--- a/core/app/helpers/spree/base_helper.rb
+++ b/core/app/helpers/spree/base_helper.rb
@@ -3,11 +3,7 @@ module Spree
def available_countries
checkout_zone = current_store.checkout_zone || Spree::Zone.default_checkout_zone
- countries = if checkout_zone && checkout_zone.kind == 'country'
- checkout_zone.country_list
- else
- Spree::Country.all
- end
+ countries = checkout_zone ? checkout_zone.country_list : Spree::Country.all
countries.collect do |country|
country.name = Spree.t(country.iso, scope: 'country_names', default: country.name)
diff --git a/core/spec/helpers/base_helper_spec.rb b/core/spec/helpers/base_helper_spec.rb
index a0f04769f9..8a6171d399 100644
--- a/core/spec/helpers/base_helper_spec.rb
+++ b/core/spec/helpers/base_helper_spec.rb
@@ -51,15 +51,17 @@ describe Spree::BaseHelper, type: :helper do
end
context 'checkout zone is of type state' do
+ let(:state) { create(:state, country: country) }
+
before do
state_zone = create(:zone, name: 'StateZone')
- state = create(:state, country: country)
state_zone.members.create(zoneable: state)
+
Spree::Config[:checkout_zone] = state_zone.name
end
- it 'return complete list of countries' do
- expect(available_countries.count).to eq(Spree::Country.count)
+ it 'returns list of countries associated with states' do
+ expect(available_countries).to contain_exactly state.country
end
end
end