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.

SD-959 rename allow_currency_change to show_store_selector

KacperMekarskiae37c375ef65
diff --git a/backend/app/controllers/spree/admin/general_settings_controller.rb b/backend/app/controllers/spree/admin/general_settings_controller.rb
index 1e5ad4783c..7dee44ef16 100644
--- a/backend/app/controllers/spree/admin/general_settings_controller.rb
+++ b/backend/app/controllers/spree/admin/general_settings_controller.rb
@@ -27,7 +27,7 @@ module Spree
end
def render(*args)
- @preferences_currency |= [:allow_currency_change]
+ @preferences_currency |= [:show_store_selector]
super
end
diff --git a/backend/app/views/spree/admin/general_settings/_form.html.erb b/backend/app/views/spree/admin/general_settings/_form.html.erb
index 3a82e8bb5f..47557c5d4a 100644
--- a/backend/app/views/spree/admin/general_settings/_form.html.erb
+++ b/backend/app/views/spree/admin/general_settings/_form.html.erb
@@ -7,10 +7,10 @@
<div class="form-group">
<div class="checkbox">
<label>
- <%= check_box('', :allow_currency_change, { checked: Spree::Config.allow_currency_change }) %>
- <%= Spree.t('allow_currency_change.short') %>
+ <%= check_box('', :show_store_selector, { checked: Spree::Config.show_store_selector }) %>
+ <%= Spree.t('show_store_selector.short') %>
</label>
- <p class="help-block"><%= Spree.t('allow_currency_change.long') %></p>
+ <p class="help-block"><%= Spree.t('show_store_selector.long') %></p>
</div>
</div>
</div>
diff --git a/backend/spec/features/admin/general_settings/prices_settings_updating_spec.rb b/backend/spec/features/admin/general_settings/prices_settings_updating_spec.rb
index 64e9ca6b9e..93c8688e95 100644
--- a/backend/spec/features/admin/general_settings/prices_settings_updating_spec.rb
+++ b/backend/spec/features/admin/general_settings/prices_settings_updating_spec.rb
@@ -7,7 +7,7 @@ describe 'Updating currencies settings', type: :feature, js: true do
describe 'enabling currency settings' do
before do
reset_spree_preferences do |config|
- config.allow_currency_change = false
+ config.show_store_selector = false
end
end
@@ -15,35 +15,35 @@ describe 'Updating currencies settings', type: :feature, js: true do
visit spree.edit_admin_general_settings_path
# Test initial state
- expect(page).to have_unchecked_field('allow_currency_change')
+ expect(page).to have_unchecked_field('show_store_selector')
# Interact with the form
- check('allow_currency_change')
+ check('show_store_selector')
click_button 'Update'
# Test final state
expect(page).to have_content 'General Settings has been successfully updated!'
- expect(page).to have_checked_field('allow_currency_change')
+ expect(page).to have_checked_field('show_store_selector')
end
end
describe 'disabling currency settings' do
before do
reset_spree_preferences do |config|
- config.allow_currency_change = true
+ config.show_store_selector = true
end
end
it 'allows to disable currency settings' do
visit spree.edit_admin_general_settings_path
- expect(page).to have_checked_field('allow_currency_change')
+ expect(page).to have_checked_field('show_store_selector')
- uncheck('allow_currency_change')
+ uncheck('show_store_selector')
click_button 'Update'
expect(page).to have_content 'General Settings has been successfully updated!'
- expect(page).to have_unchecked_field('allow_currency_change')
+ expect(page).to have_unchecked_field('show_store_selector')
end
end
end
diff --git a/core/app/models/spree/app_configuration.rb b/core/app/models/spree/app_configuration.rb
index 4000ec9002..d91c4feea8 100644
--- a/core/app/models/spree/app_configuration.rb
+++ b/core/app/models/spree/app_configuration.rb
@@ -69,7 +69,7 @@ module Spree
preference :credit_to_new_allocation, :boolean, default: false
# Multi currency configurations
- preference :allow_currency_change, :boolean, default: false
+ preference :show_store_selector, :boolean, default: false
# searcher_class allows spree extension writers to provide their own Search class
def searcher_class
diff --git a/core/app/models/spree/line_item.rb b/core/app/models/spree/line_item.rb
index 8a2ee06777..13deb0dc89 100644
--- a/core/app/models/spree/line_item.rb
+++ b/core/app/models/spree/line_item.rb
@@ -57,7 +57,7 @@ module Spree
end
def update_price
- if Spree::Config.allow_currency_change == true
+ if Spree::Config.show_store_selector == true
currency_price = Spree::Price.where(
currency: order.currency,
variant_id: variant_id
diff --git a/core/config/locales/en.yml b/core/config/locales/en.yml
index c91aec85b9..06d38f928a 100644
--- a/core/config/locales/en.yml
+++ b/core/config/locales/en.yml
@@ -574,9 +574,6 @@ en:
agree_to_privacy_policy: Agree to Privacy Policy
agree_to_terms_of_service: Agree to Terms of Service
all: All
- allow_currency_change:
- short: Allow Currency Change
- long: Display the currency picker in the main nav bar and allow users to change their currency via it. In addition, multiple stores must be supported.
all_adjustments_closed: All adjustments successfully closed!
all_adjustments_opened: All adjustments successfully opened!
all_departments: All departments
@@ -1576,6 +1573,9 @@ en:
show_only_considered_risky: Only show risky orders
show_property: Show Property
show_rate_in_label: Show rate in label
+ show_store_selector:
+ short: Allow Currency Change
+ long: Display the currency picker in the main nav bar and allow users to change their currency via it. In addition, multiple stores must be supported.
sign_up: Sign Up
sku: SKU
skus: SKUs
diff --git a/core/spec/models/spree/line_item_spec.rb b/core/spec/models/spree/line_item_spec.rb
index b047bd3cd4..367f7f6d56 100644
--- a/core/spec/models/spree/line_item_spec.rb
+++ b/core/spec/models/spree/line_item_spec.rb
@@ -187,7 +187,7 @@ describe Spree::LineItem, type: :model do
expect(price).to receive(:price_including_vat_for).and_return(12)
reset_spree_preferences do |config|
- config.allow_currency_change = true
+ config.show_store_selector = true
end
end
diff --git a/frontend/app/controllers/spree/currency_controller.rb b/frontend/app/controllers/spree/currency_controller.rb
index 79a4e9f8ff..ce274d82e7 100644
--- a/frontend/app/controllers/spree/currency_controller.rb
+++ b/frontend/app/controllers/spree/currency_controller.rb
@@ -4,7 +4,7 @@ module Spree
@currency = supported_currencies.find { |currency| currency.iso_code == params[:currency] }
# Make sure that we update the current order, so the currency change is reflected.
current_order&.update_attributes!(currency: @currency.iso_code)
- session[:currency] = params[:currency] if Spree::Config[:allow_currency_change]
+ session[:currency] = params[:currency] if Spree::Config[:show_store_selector]
respond_to do |format|
format.json { render json: [email protected]? }
format.html do
diff --git a/frontend/app/views/spree/shared/_change_store.html.erb b/frontend/app/views/spree/shared/_change_store.html.erb
index 2f12c1c3b4..d76d0245a8 100644
--- a/frontend/app/views/spree/shared/_change_store.html.erb
+++ b/frontend/app/views/spree/shared/_change_store.html.erb
@@ -1,4 +1,4 @@
-<% if Spree::Config.allow_currency_change && stores.size > 1 %>
+<% if Spree::Config.show_store_selector && stores.size > 1 %>
<li class="change-store">
<div class="dropdown navbar-right-dropdown">
<button id="stores-button" type="button" data-toggle="dropdown" class="navbar-right-dropdown-toggle" aria-label="<%= Spree.t('nav_bar.change_country')%>">
diff --git a/frontend/spec/features/main_nav_bar_spec.rb b/frontend/spec/features/main_nav_bar_spec.rb
index bad7065ab8..d1875c252a 100644
--- a/frontend/spec/features/main_nav_bar_spec.rb
+++ b/frontend/spec/features/main_nav_bar_spec.rb
@@ -12,12 +12,12 @@ describe 'Main navigation bar', type: :feature do
end
end
- context 'when allow_currency_change preference is set to true' do
+ context 'when show_store_selector preference is set to true' do
let!(:stores) { create_list(:store, stores_number, default_country: create(:country)) }
before do
reset_spree_preferences do |config|
- config.allow_currency_change = true
+ config.show_store_selector = true
end
visit spree.root_path
@@ -51,12 +51,12 @@ describe 'Main navigation bar', type: :feature do
end
end
- context 'when allow_currency_change preference is set to false' do
+ context 'when show_store_selector preference is set to false' do
let!(:stores) { create_list(:store, stores_number) }
before do
reset_spree_preferences do |config|
- config.allow_currency_change = false
+ config.show_store_selector = false
end
visit spree.root_path
diff --git a/frontend/spec/features/order_prices_spec.rb b/frontend/spec/features/order_prices_spec.rb
index 618d081ddf..28ca5eb0bf 100644
--- a/frontend/spec/features/order_prices_spec.rb
+++ b/frontend/spec/features/order_prices_spec.rb
@@ -6,8 +6,7 @@ xdescribe 'Order', type: :feature, js: true do
before do
reset_spree_preferences do |config|
- config.allow_currency_change = true
- config.show_currency_selector = true
+ config.show_store_selector = true
end
create(:price, variant: product.master, currency: 'EUR', amount: 16.00)
diff --git a/frontend/spec/features/product_prices_spec.rb b/frontend/spec/features/product_prices_spec.rb
index 7304bb6354..35686247da 100644
--- a/frontend/spec/features/product_prices_spec.rb
+++ b/frontend/spec/features/product_prices_spec.rb
@@ -8,8 +8,7 @@ describe 'Product with prices in multiple currencies', type: :feature, js: true
before do
reset_spree_preferences do |config|
- config.allow_currency_change = true
- config.show_currency_selector = true
+ config.show_store_selector = true
end
create(:price, variant: product.master, currency: 'EUR', amount: 16.00)
create(:price, variant: product.master, currency: 'GBP', amount: 23.00)
@@ -24,11 +23,10 @@ describe 'Product with prices in multiple currencies', type: :feature, js: true
expect(page).to have_text '£23.00'
end
- context 'and :show_currency_selector is false' do
+ context 'and :show_store_selector is false' do
before do
reset_spree_preferences do |config|
- config.allow_currency_change = true
- config.show_currency_selector = false
+ config.show_store_selector = false
end
end
@@ -38,23 +36,6 @@ describe 'Product with prices in multiple currencies', type: :feature, js: true
expect(page).to_not have_text 'Currency'
end
end
-
- context 'and :allow_currency_change is false' do
- context 'and show_currency_selector is true' do
- before do
- reset_spree_preferences do |config|
- config.allow_currency_change = false
- config.show_currency_selector = true
- end
- end
-
- it 'will not render the currency selector' do
- visit spree.product_path(product)
- expect(page).to have_current_path(spree.product_path(product))
- expect(page).to_not have_text 'Currency'
- end
- end
- end
end
end