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.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Additional tests
Damian Legawiec3b5395412639
diff --git a/backend/app/controllers/spree/admin/stores_controller.rb b/backend/app/controllers/spree/admin/stores_controller.rbindex 2d1bc754c0..b0e2916df1 100644--- a/backend/app/controllers/spree/admin/stores_controller.rb+++ b/backend/app/controllers/spree/admin/stores_controller.rb@@ -5,6 +5,7 @@ module Spreebefore_action :set_default_currency, only: :newbefore_action :set_default_locale, only: :newbefore_action :normalize_supported_currencies, only: [:create, :update]+ before_action :normalize_supported_locales, only: [:create, :update]before_action :set_default_country_id, only: :newbefore_action :load_all_countries, only: [:new, :edit, :update, :create]before_action :load_all_zones, only: %i[new edit]@@ -127,6 +128,12 @@ module Spreeendend+ def normalize_supported_locales+ if params[:store][:supported_locales]&.is_a?(Array)+ params[:store][:supported_locales] = params[:store][:supported_locales].compact.uniq.reject(&:blank?).join(',')+ end+ end+def set_default_country_id@store.default_country_id = Spree::Config[:default_country_id]enddiff --git a/backend/spec/features/admin/configuration/stores_spec.rb b/backend/spec/features/admin/configuration/stores_spec.rbindex 3089eb4c0a..8215b6301f 100644--- a/backend/spec/features/admin/configuration/stores_spec.rb+++ b/backend/spec/features/admin/configuration/stores_spec.rb@@ -8,6 +8,15 @@ describe 'Stores admin', type: :feature, js: true dolet!(:no_limits) { create(:zone, name: 'No Limits') }describe 'visiting the stores page' do+ before do+ store.update(+ name: 'My Store',+ url: 'example.com',+ supported_currencies: 'USD,EUR',+ supported_locales: 'fr,de'+ )+ end+it 'is on the stores page' dovisit spree.admin_stores_path@@ -15,8 +24,10 @@ describe 'Stores admin', type: :feature, js: true dorow_count = store_table.all(:css, 'tr').sizeexpect(row_count).to eq 2expect(Spree::Store.count).to eq 1- expect(store_table).to have_content(store.name)- expect(store_table).to have_content(store.url)+ expect(store_table).to have_content('My Store')+ expect(store_table).to have_content('example.com')+ expect(store_table).to have_content('USD, EUR')+ expect(store_table).to have_content('fr, de')endend@@ -73,14 +84,27 @@ describe 'Stores admin', type: :feature, js: true dopage.fill_in 'store_code', with: 'spree'page.fill_in 'store_mail_from_address', with: '[email protected]'page.fill_in 'store_customer_support_email', with: '[email protected]'- select2 'EUR', from: 'Currency'+ select2 'EUR', from: 'Default currency'+ select2_clear from: 'Supported Currencies'+ select2_search 'GBP', from: 'Supported Currencies'+ select2_select 'GBP', from: 'Supported Currencies'++ select2 'English (US)', from: 'Default locale'+click_button 'Create'expect(page).to have_current_path spree.admin_stores_path+ expect(page).to have_content('successfully created!')row_count = page.all(:css, 'table tr').sizeexpect(row_count).to eq 3expect(Spree::Store.count).to eq 2++ store = Spree::Store.last++ expect(store.default_currency).to eq 'EUR'+ expect(store.supported_currencies_list.map(&:iso_code)).to contain_exactly('EUR', 'GBP')+ expect(store.default_locale).to eq 'en'endend@@ -95,7 +119,7 @@ describe 'Stores admin', type: :feature, js: true doclick_icon :editendpage.fill_in 'store_name', with: updated_name- select2 new_currency, from: 'Currency'+ select2 new_currency, from: 'Default currency'click_button 'Update'expect(page).to have_current_path spree.admin_stores_pathdiff --git a/core/spec/lib/spree/core/controller_helpers/locale_spec.rb b/core/spec/lib/spree/core/controller_helpers/locale_spec.rbindex c3a1f5236f..db89c30c2e 100644--- a/core/spec/lib/spree/core/controller_helpers/locale_spec.rb+++ b/core/spec/lib/spree/core/controller_helpers/locale_spec.rb@@ -17,12 +17,17 @@ describe Spree::Core::ControllerHelpers::Locale, type: :controller docontroller(FakesController) {}describe '#current_locale' do- context 'store with local set' do- let!(:store) { create :store, default: true, default_locale: 'fr' }+ context 'store with locale set' do+ let!(:store) { create :store, default: true, default_locale: 'fr', supported_locales: 'fr,de' }it 'returns current store default locale' doexpect(controller.current_locale.to_s).to eq('fr')end++ it 'return supported locale when passed as param' do+ controller.params = { locale: 'de' }+ expect(controller.current_locale.to_s).to eq('de')+ endendcontext 'config_locale present' do