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 Store#supported_locales_list method

Damian Legawiecbf7008db0ec3
diff --git a/core/app/models/spree/store.rb b/core/app/models/spree/store.rb
index 47f9061fbe..3901798551 100644
--- a/core/app/models/spree/store.rb
+++ b/core/app/models/spree/store.rb
@@ -49,6 +49,11 @@ module Spree
end.uniq.compact
end
+ def supported_locales_list
+ # TODO: add support of multiple supported languages to a single Store
+ [default_locale].compact.uniq
+ end
+
def unique_name
"#{name} (#{code})"
end
diff --git a/core/spec/models/spree/store_spec.rb b/core/spec/models/spree/store_spec.rb
index 00f28b11a0..c6c31f48b2 100644
--- a/core/spec/models/spree/store_spec.rb
+++ b/core/spec/models/spree/store_spec.rb
@@ -83,7 +83,7 @@ describe Spree::Store, type: :model do
end
end
- context '.unique_name' do
+ describe '#unique_name' do
let!(:store) { create(:store) }
it 'returns the Store Name followed by the Store Code in parentheses' do
@@ -91,7 +91,7 @@ describe Spree::Store, type: :model do
end
end
- describe '.supported_currencies_list' do
+ describe '#supported_currencies_list' do
context 'with supported currencies set' do
let(:currencies) { 'USD, EUR, dummy' }
let!(:store) { create(:store, default_currency: 'USD', supported_currencies: currencies) }
@@ -113,6 +113,26 @@ describe Spree::Store, type: :model do
end
end
end
+
+ describe '#supported_locales_list' do
+ context 'with supported locale set' do
+ let(:store) { create(:store, default_locale: 'fr') }
+
+ it 'returns supported currencies list' do
+ expect(store.supported_locales_list).to be_an_instance_of(Array)
+ expect(store.supported_locales_list).to contain_exactly('fr')
+ end
+ end
+
+ context 'without supported currencies set' do
+ let(:store) { create(:store) }
+
+ it 'returns supported currencies list' do
+ expect(store.supported_locales_list).to be_an_instance_of(Array)
+ expect(store.supported_locales_list).to be_empty
+ end
+ end
+ end
end
shared_context 'with checkout zone set' do