Skip to content

Commit

Permalink
Remove unnecessary storage of currency
Browse files Browse the repository at this point in the history
  • Loading branch information
mkllnk committed Jan 3, 2025
1 parent 1952655 commit fe3c96e
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 26 deletions.
16 changes: 0 additions & 16 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions spec/base_spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions spec/lib/spree/money_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

before do
configure_spree_preferences do |config|
config.currency = "USD"
config.currency_symbol_position = :before
config.display_currency = false
end
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/models/spree/adjustment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/models/spree/order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/models/spree/variant_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/system/admin/reports_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fe3c96e

Please sign in to comment.