Fix deprecated syntax on associations

This commit is contained in:
Matt-Yorkley
2019-12-21 13:50:47 +01:00
committed by Luis Ramos
parent 5cc223e8f4
commit 0a9d63dd2f
2 changed files with 5 additions and 5 deletions

View File

@@ -9,8 +9,9 @@ module Spree
# So we don't need the option `dependent: :destroy` as long as
# AdjustmentMetadata has no destroy logic itself.
has_one :metadata, class_name: 'AdjustmentMetadata'
belongs_to :tax_rate, foreign_key: 'originator_id',
conditions: "spree_adjustments.originator_type = 'Spree::TaxRate'"
belongs_to :tax_rate, -> { where spree_adjustments: { originator_type: 'Spree::TaxRate' } },
foreign_key: 'originator_id'
scope :enterprise_fee, -> { where(originator_type: 'EnterpriseFee') }
scope :admin, -> { where(source_type: nil, originator_type: nil) }

View File

@@ -21,10 +21,9 @@ Spree::Order.class_eval do
# This removes "inverse_of: source" which breaks shipment adjustment calculations
# This change is done in Spree 2.1 (see https://github.com/spree/spree/commit/3fa44165c7825f79a2fa4eb79b99dc29944c5d55)
# When OFN gets to Spree 2.1, this can be removed
has_many :adjustments,
has_many :adjustments, -> { order "#{Spree::Adjustment.table_name}.created_at ASC" },
as: :adjustable,
dependent: :destroy,
order: "#{Spree::Adjustment.table_name}.created_at ASC"
dependent: :destroy
validates :customer, presence: true, if: :require_customer?
validate :products_available_from_new_distribution, if: lambda { distributor_id_changed? || order_cycle_id_changed? }