Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused app config options #13058

Merged
merged 3 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/helpers/spree/base_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Spree
module BaseHelper
def available_countries
checkout_zone = Zone.find_by(name: Spree::Config[:checkout_zone])
checkout_zone = Zone.find_by(name: ENV.fetch("CHECKOUT_ZONE", nil))

countries = if checkout_zone && checkout_zone.kind == 'country'
checkout_zone.countries
Expand Down
3 changes: 0 additions & 3 deletions app/models/spree/app_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ class AppConfiguration < Preferences::Configuration
preference :allow_backorder_shipping, :boolean, default: false
preference :allow_checkout_on_gateway_error, :boolean, default: false
preference :allow_guest_checkout, :boolean, default: true
# Replace with the name of a zone if you would like to limit the countries
preference :checkout_zone, :string, default: nil
preference :currency, :string, default: "USD"
preference :currency_decimal_mark, :string, default: "."
preference :currency_symbol_position, :string, default: "before"
preference :currency_thousands_separator, :string, default: ","
Expand Down
17 changes: 0 additions & 17 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +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['checkout_zone'] = ENV['CHECKOUT_ZONE']
Spree::Config['currency'] = ENV['CURRENCY']
end
end

dacook marked this conversation as resolved.
Show resolved Hide resolved
initializer "load_spree_calculators" do |app|
# Register Spree calculators
Rails.application.reloader.to_prepare do
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

class DeleteCheckoutZoneAndCurrencyPreferences < ActiveRecord::Migration[7.0]
def up
execute <<~SQL

Check warning on line 5 in db/migrate/20250103043626_delete_checkout_zone_and_currency_preferences.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Use `<<~SQL.squish` instead of `<<~SQL`. Raw Output: db/migrate/20250103043626_delete_checkout_zone_and_currency_preferences.rb:5:13: C: Rails/SquishedSQLHeredocs: Use `<<~SQL.squish` instead of `<<~SQL`.
DELETE FROM spree_preferences
WHERE key IN (
'/spree/app_configuration/checkout_zone',
'/spree/app_configuration/currency'
)
SQL
end
end
4 changes: 0 additions & 4 deletions spec/base_spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,11 @@
end

default_country_id = DefaultCountry.id
checkout_zone = Spree::Config[:checkout_zone]
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.checkout_zone = checkout_zone
spree_config.currency = currency
spree_config.shipping_instructions = true
end
CurrentConfig.clear_all
Expand Down
7 changes: 4 additions & 3 deletions spec/helpers/spree/base_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@

before do
3.times { create(:country) }
allow(ENV).to receive(:fetch).and_call_original
end

context "with no checkout zone defined" do
before do
Spree::Config[:checkout_zone] = nil
allow(ENV).to receive(:fetch).and_return(nil)
dacook marked this conversation as resolved.
Show resolved Hide resolved
end

it "return complete list of countries" do
Expand All @@ -27,7 +28,7 @@
before do
@country_zone = create(:zone, name: "CountryZone")
@country_zone.members.create(zoneable: country)
Spree::Config[:checkout_zone] = @country_zone.name
allow(ENV).to receive(:fetch).and_return(@country_zone.name)
end

it "return only the countries defined by the checkout zone" do
Expand All @@ -40,7 +41,7 @@
state_zone = create(:zone, name: "StateZone")
state = create(:state, country:)
state_zone.members.create(zoneable: state)
Spree::Config[:checkout_zone] = state_zone.name
allow(ENV).to receive(:fetch).and_return(state_zone.name)
end

it "return complete list of countries" do
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
Loading