mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-04 02:31:33 +00:00
Remove unnecessary storage of currency
This commit is contained in:
@@ -81,22 +81,6 @@ module Openfoodnetwork
|
||||
]
|
||||
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
|
||||
|
||||
@@ -235,13 +235,11 @@ RSpec.configure do |config|
|
||||
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
|
||||
|
||||
@@ -7,7 +7,6 @@ RSpec.describe Spree::Money do
|
||||
|
||||
before do
|
||||
configure_spree_preferences do |config|
|
||||
config.currency = "USD"
|
||||
config.currency_symbol_position = :before
|
||||
config.display_currency = false
|
||||
end
|
||||
@@ -97,7 +96,6 @@ RSpec.describe Spree::Money do
|
||||
context "EUR" do
|
||||
before do
|
||||
configure_spree_preferences do |config|
|
||||
config.currency = "EUR"
|
||||
config.currency_symbol_position = :after
|
||||
config.display_currency = false
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -516,7 +516,7 @@ RSpec.describe Spree::Order do
|
||||
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
|
||||
|
||||
@@ -292,7 +292,7 @@ RSpec.describe Spree::Variant do
|
||||
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 @@ RSpec.describe Spree::Variant do
|
||||
|
||||
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
|
||||
|
||||
@@ -737,7 +737,7 @@ RSpec.describe '
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user