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.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Deprecate Country#default method
Damian Legawiecf208dae791b6
diff --git a/api/spec/requests/spree/api/v2/storefront/checkout_spec.rb b/api/spec/requests/spree/api/v2/storefront/checkout_spec.rbindex fef953e14b..1349a65b25 100644--- a/api/spec/requests/spree/api/v2/storefront/checkout_spec.rb+++ b/api/spec/requests/spree/api/v2/storefront/checkout_spec.rb@@ -577,7 +577,7 @@ describe 'API V2 Storefront Checkout Spec', type: :request dodescribe 'checkout#shipping_rates' dolet(:execute) { get '/api/v2/storefront/checkout/shipping_rates', headers: headers }- let(:country) { Spree::Country.default }+ let(:country) { store.default_country }let(:zone) { create(:zone, name: 'US') }let(:shipping_method) { create(:shipping_method) }let(:shipping_method_2) { create(:shipping_method) }diff --git a/core/app/models/spree/country.rb b/core/app/models/spree/country.rbindex ff72498806..ac0afd6852 100644--- a/core/app/models/spree/country.rb+++ b/core/app/models/spree/country.rb@@ -19,6 +19,10 @@ module Spreevalidates :name, :iso_name, :iso, :iso3, presence: true, uniqueness: { case_sensitive: false }def self.default(store = nil)+ ActiveSupport::Deprecation.warn(<<-DEPRECATION, caller)+ `Country#default` is deprecated and will be removed in Spree 5.0.+ Please use `current_store.default_country` instead+ DEPRECATIONstore ||= Spree::Store.defaultcountry_id = store.default_country_iddefault = find_by(id: country_id) if country_id.present?diff --git a/core/app/models/spree/store.rb b/core/app/models/spree/store.rbindex 9585722d42..46f47a8562 100644--- a/core/app/models/spree/store.rb+++ b/core/app/models/spree/store.rb@@ -158,7 +158,7 @@ module Spreeself.default_country = if checkout_zone.present? && checkout_zone.country_list.any?checkout_zone.country_list.firstelse- Country.default+ Country.find_by(iso: 'US') || Country.firstendendenddiff --git a/sample/db/samples/stores.rb b/sample/db/samples/stores.rbindex b8fa63a047..533e7dd343 100644--- a/sample/db/samples/stores.rb+++ b/sample/db/samples/stores.rb@@ -1,6 +1,6 @@default_store = Spree::Store.defaultdefault_store.checkout_zone = Spree::Zone.find_by(name: 'North America')-default_store.default_country = Spree::Country.default+default_store.default_country = Spree::Country.find_by(iso: 'US')default_store.supported_currencies = 'CAD,USD'default_store.supported_locales = 'en,fr'default_store.url = Rails.env.development? ? 'localhost:3000' : 'demo.spreecommerce.org'