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 NavigationHelper#should_render_internationalization_dropdown?

Damian Legawiec230ed11f1c9e
diff --git a/frontend/app/helpers/spree/navigation_helper.rb b/frontend/app/helpers/spree/navigation_helper.rb
index e584f9fa5c..a8958d584b 100644
--- a/frontend/app/helpers/spree/navigation_helper.rb
+++ b/frontend/app/helpers/spree/navigation_helper.rb
@@ -28,6 +28,11 @@ module Spree
)
end
+ def should_render_internationalization_dropdown?
+ (defined?(should_render_locale_dropdown?) && should_render_locale_dropdown?) ||
+ (defined?(should_render_currency_dropdown?) && should_render_currency_dropdown?)
+ end
+
private
def spree_navigation_data_cache_key
diff --git a/frontend/spec/helpers/navigation_helper_spec.rb b/frontend/spec/helpers/navigation_helper_spec.rb
new file mode 100644
index 0000000000..76905a1122
--- /dev/null
+++ b/frontend/spec/helpers/navigation_helper_spec.rb
@@ -0,0 +1,34 @@
+require 'spec_helper'
+
+module Spree
+ describe NavigationHelper, type: :helper do
+ include Spree::CurrencyHelper
+ include Spree::LocaleHelper
+
+ describe '#should_render_internationalization_dropdown?' do
+ context 'store with multiple currencies' do
+ let(:current_store) { create(:store, supported_currencies: 'EUR,USD') }
+
+ it { expect(should_render_internationalization_dropdown?).to be_truthy }
+ end
+
+ context 'store with multiple locales' do
+ let(:current_store) { create(:store, supported_locales: 'en,fr') }
+
+ it { expect(should_render_internationalization_dropdown?).to be_truthy }
+ end
+
+ context 'store with multiple currencies and locales' do
+ let(:current_store) { create(:store, supported_currencies: 'EUR,USD', supported_locales: 'en,fr') }
+
+ it { expect(should_render_internationalization_dropdown?).to be_truthy }
+ end
+
+ context 'store with single currency and locale' do
+ let(:current_store) { create(:store, supported_currencies: nil, supported_locales: nil) }
+
+ it { expect(should_render_internationalization_dropdown?).to be_falsey }
+ end
+ end
+ end
+end