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.

Added StoreHelper#should_render_store_chooser?

Damian Legawiec4feeef3d3920
diff --git a/frontend/app/helpers/spree/store_helper.rb b/frontend/app/helpers/spree/store_helper.rb
index 89eac8e08a..76be480c3c 100644
--- a/frontend/app/helpers/spree/store_helper.rb
+++ b/frontend/app/helpers/spree/store_helper.rb
@@ -27,5 +27,9 @@ module Spree
Spree.t('i18n.this_file_language', locale: store.default_locale)
end
+
+ def should_render_store_chooser?
+ Spree::Config.show_store_selector && stores.size > 1
+ end
end
end
diff --git a/frontend/spec/helpers/store_helper_spec.rb b/frontend/spec/helpers/store_helper_spec.rb
index 7e62b7b91c..a13cecfadf 100644
--- a/frontend/spec/helpers/store_helper_spec.rb
+++ b/frontend/spec/helpers/store_helper_spec.rb
@@ -37,5 +37,27 @@ module Spree
it { expect(store_locale_name(Spree::Store.default)).to eq('English (US)') }
it { expect(store_locale_name(eu_store)).to eq('Deutsch (DE)') }
end
+
+ describe '#should_render_store_chooser?' do
+ context 'enabled' do
+ context 'with 1 store' do
+ it { expect(should_render_store_chooser?).to be_falsey }
+ end
+
+ context 'with multiple stores' do
+ before { create_list(:store, 2) }
+
+ it { expect(should_render_store_chooser?).to be_truthy }
+ end
+ end
+
+ context 'disabled' do
+ before { Spree::Config.show_store_selector = false }
+
+ after { Spree::Config.show_store_selector = true }
+
+ it { expect(should_render_store_chooser?).to be_falsey }
+ end
+ end
end
end