From fe3c96e91543e007edbc8963cc249cdfe6bb65be Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Fri, 3 Jan 2025 15:32:58 +1100 Subject: [PATCH] Remove unnecessary storage of currency --- config/application.rb | 16 ---------------- spec/base_spec_helper.rb | 2 -- spec/lib/spree/money_spec.rb | 2 -- spec/models/spree/adjustment_spec.rb | 4 ++-- spec/models/spree/order_spec.rb | 2 +- spec/models/spree/variant_spec.rb | 4 ++-- spec/system/admin/reports_spec.rb | 2 +- 7 files changed, 6 insertions(+), 26 deletions(-) diff --git a/config/application.rb b/config/application.rb index 05d7cef54e7..a6e2dc3398f 100644 --- a/config/application.rb +++ b/config/application.rb @@ -81,22 +81,6 @@ class Application < Rails::Application ] end - # Settings dependent on locale - # - # We need to set this config before the promo environment gets loaded and - # after the spree environment gets loaded... - # This is because Spree uses `Spree::Config` while evaluating classes :scream: - # - # https://github.com/spree/spree/blob/2-0-stable/core/app/models/spree/calculator/per_item.rb#L6 - # - # TODO: move back to spree initializer once we upgrade to a more recent version - # of Spree - initializer 'ofn.spree_locale_settings', before: 'spree.promo.environment' do |app| - Rails.application.reloader.to_prepare do - Spree::Config['currency'] = ENV['CURRENCY'] - end - end - initializer "load_spree_calculators" do |app| # Register Spree calculators Rails.application.reloader.to_prepare do diff --git a/spec/base_spec_helper.rb b/spec/base_spec_helper.rb index 9c9d9a8f43c..a9fd8cadc7a 100644 --- a/spec/base_spec_helper.rb +++ b/spec/base_spec_helper.rb @@ -235,13 +235,11 @@ end default_country_id = DefaultCountry.id - currency = Spree::Config[:currency] # Ensure we start with consistent config settings config.before(:each) do reset_spree_preferences do |spree_config| # These are all settings that differ from Spree's defaults spree_config.default_country_id = default_country_id - spree_config.currency = currency spree_config.shipping_instructions = true end CurrentConfig.clear_all diff --git a/spec/lib/spree/money_spec.rb b/spec/lib/spree/money_spec.rb index e79443e9209..a32d8576c63 100644 --- a/spec/lib/spree/money_spec.rb +++ b/spec/lib/spree/money_spec.rb @@ -7,7 +7,6 @@ before do configure_spree_preferences do |config| - config.currency = "USD" config.currency_symbol_position = :before config.display_currency = false end @@ -97,7 +96,6 @@ context "EUR" do before do configure_spree_preferences do |config| - config.currency = "EUR" config.currency_symbol_position = :after config.display_currency = false end diff --git a/spec/models/spree/adjustment_spec.rb b/spec/models/spree/adjustment_spec.rb index 9682d045ee8..abf3bcfb408 100644 --- a/spec/models/spree/adjustment_spec.rb +++ b/spec/models/spree/adjustment_spec.rb @@ -133,7 +133,7 @@ module Spree before { Spree::Config[:display_currency] = true } it "shows the currency" do - expect(adjustment.display_amount.to_s).to eq "$10.55 #{Spree::Config[:currency]}" + expect(adjustment.display_amount.to_s).to eq "$10.55 AUD" end end @@ -167,7 +167,7 @@ module Spree context '#currency' do it 'returns the globally configured currency' do - expect(adjustment.currency).to eq Spree::Config[:currency] + expect(adjustment.currency).to eq "AUD" end end diff --git a/spec/models/spree/order_spec.rb b/spec/models/spree/order_spec.rb index 00a0cdb6214..5abc19da12d 100644 --- a/spec/models/spree/order_spec.rb +++ b/spec/models/spree/order_spec.rb @@ -516,7 +516,7 @@ before { order.currency = nil } it "returns the globally configured currency" do - expect(order.currency).to eq Spree::Config[:currency] + expect(order.currency).to eq "AUD" end end end diff --git a/spec/models/spree/variant_spec.rb b/spec/models/spree/variant_spec.rb index 70068b41645..73754aaa72a 100644 --- a/spec/models/spree/variant_spec.rb +++ b/spec/models/spree/variant_spec.rb @@ -292,7 +292,7 @@ context "#currency" do it "returns the globally configured currency" do variant.save! - expect(variant.currency).to eq Spree::Config[:currency] + expect(variant.currency).to eq "AUD" end end @@ -309,7 +309,7 @@ it "populates cost currency with the default value on save" do variant.save! - expect(variant.cost_currency).to eq Spree::Config[:currency] + expect(variant.cost_currency).to eq "AUD" end end end diff --git a/spec/system/admin/reports_spec.rb b/spec/system/admin/reports_spec.rb index 072c546646a..2d689ff7a04 100644 --- a/spec/system/admin/reports_spec.rb +++ b/spec/system/admin/reports_spec.rb @@ -737,7 +737,7 @@ def xero_invoice_row(sku, description, amount, quantity, tax_type, opts = {}) sku, description, quantity, - amount.to_s, '', opts[:account_code], tax_type, '', '', '', '', Spree::Config.currency, + amount.to_s, '', opts[:account_code], tax_type, '', '', '', '', "AUD", '', 'N'] end end