mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Remove non need belongs_to associations from Adjustments
It turns out the "tax_rate" association isn't used and wasn't working. Same for the "voucher" one, which I added to be consistent with existing code. Both of these weren't caught by the specs because you can't test associations with a custome relation with 'shouda-matchers' see: https://github.com/thoughtbot/shoulda-matchers/issues/981
This commit is contained in:
committed by
Maikel Linke
parent
b67f5ae154
commit
d29119f5c5
@@ -42,11 +42,6 @@ module Spree
|
||||
belongs_to :order, class_name: "Spree::Order"
|
||||
belongs_to :tax_category, class_name: 'Spree::TaxCategory'
|
||||
|
||||
belongs_to :tax_rate, -> { where spree_adjustments: { originator_type: 'Spree::TaxRate' } },
|
||||
foreign_key: 'originator_id'
|
||||
belongs_to :voucher, -> { where spree_adjustments: { originator_type: 'Voucher' } },
|
||||
foreign_key: 'originator_id', inverse_of: :adjustments
|
||||
|
||||
validates :label, presence: true
|
||||
validates :amount, numericality: true
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ class Voucher < ApplicationRecord
|
||||
has_many :adjustments,
|
||||
as: :originator,
|
||||
class_name: 'Spree::Adjustment',
|
||||
inverse_of: :voucher,
|
||||
dependent: :nullify
|
||||
|
||||
validates :code, presence: true, uniqueness: { scope: :enterprise_id }
|
||||
|
||||
@@ -11,14 +11,10 @@ module Spree
|
||||
it { is_expected.to have_one(:metadata) }
|
||||
it { is_expected.to have_many(:adjustments) }
|
||||
|
||||
it { is_expected.to belong_to(:adjustable) }
|
||||
|
||||
it { is_expected.to belong_to(:adjustable) }
|
||||
it { is_expected.to belong_to(:originator) }
|
||||
it { is_expected.to belong_to(:order) }
|
||||
it { is_expected.to belong_to(:tax_category) }
|
||||
it { is_expected.to belong_to(:tax_rate) }
|
||||
it { is_expected.to belong_to(:voucher) }
|
||||
end
|
||||
|
||||
describe "scopes" do
|
||||
|
||||
Reference in New Issue
Block a user