Skip to content

armgit / spree

Public Imported from GitHub
0

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.

fixed rails 7.2 deprecations (#12039)

Damian Legawiec753e27187669
diff --git a/.rubocop.yml b/.rubocop.yml
index 55112ee247..0b0b914dd8 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -143,6 +143,9 @@ Style/HashTransformKeys:
Style/HashTransformValues:
Enabled: false
+Style/Alias:
+ Enabled: false
+
RSpec/NestedGroups:
Max: 7
diff --git a/core/app/models/concerns/spree/user_address.rb b/core/app/models/concerns/spree/user_address.rb
index 7078115ea6..e53febe004 100644
--- a/core/app/models/concerns/spree/user_address.rb
+++ b/core/app/models/concerns/spree/user_address.rb
@@ -5,11 +5,13 @@ module Spree
included do
belongs_to :bill_address, foreign_key: :bill_address_id, class_name: 'Spree::Address',
optional: true
- alias_attribute :billing_address, :bill_address
+ alias_method :billing_address, :bill_address
+ alias_method :billing_address=, :bill_address=
belongs_to :ship_address, foreign_key: :ship_address_id, class_name: 'Spree::Address',
optional: true
- alias_attribute :shipping_address, :ship_address
+ alias_method :shipping_address, :ship_address
+ alias_method :shipping_address=, :ship_address=
accepts_nested_attributes_for :ship_address, :bill_address
diff --git a/core/app/models/spree/credit_card.rb b/core/app/models/spree/credit_card.rb
index d9bf218c5b..b58579752d 100644
--- a/core/app/models/spree/credit_card.rb
+++ b/core/app/models/spree/credit_card.rb
@@ -99,13 +99,15 @@ module Spree
def cc_type=(type)
self[:cc_type] = case type
when 'mastercard', 'maestro' then 'master'
- when 'amex' then 'american_express'
+ when 'amex' then 'american_express'
when 'dinersclub' then 'diners_club'
when '' then try_type_from_number
else type
end
end
+ alias_method :brand=, :cc_type=
+
def verification_value=(value)
@verification_value = value.to_s.gsub(/\s/, '')
end
diff --git a/core/app/models/spree/order.rb b/core/app/models/spree/order.rb
index 97b1ac4914..ed612c56b3 100644
--- a/core/app/models/spree/order.rb
+++ b/core/app/models/spree/order.rb
@@ -102,11 +102,13 @@ module Spree
belongs_to :bill_address, foreign_key: :bill_address_id, class_name: 'Spree::Address',
optional: true, dependent: :destroy
- alias_attribute :billing_address, :bill_address
+ alias_method :billing_address, :bill_address
+ alias_method :billing_address=, :bill_address=
belongs_to :ship_address, foreign_key: :ship_address_id, class_name: 'Spree::Address',
optional: true, dependent: :destroy
- alias_attribute :shipping_address, :ship_address
+ alias_method :shipping_address, :ship_address
+ alias_method :shipping_address=, :ship_address=
belongs_to :store, class_name: 'Spree::Store'
diff --git a/core/app/models/spree/price.rb b/core/app/models/spree/price.rb
index ab1b2b4449..1d2dc7dfa4 100644
--- a/core/app/models/spree/price.rb
+++ b/core/app/models/spree/price.rb
@@ -46,7 +46,9 @@ module Spree
end
alias_attribute :price, :amount
+ alias_method :price=, :amount=
alias_attribute :compare_at_price, :compare_at_amount
+ alias_method :compare_at_price=, :compare_at_amount=
def price_including_vat_for(price_options)
options = price_options.merge(tax_category: variant.tax_category)