Merge pull request #6556 from Matt-Yorkley/adjustments-eligible

[Adjustments] Delete dead code #eligible_for_originator?
This commit is contained in:
Andy Brett
2021-01-01 20:48:27 -08:00
committed by GitHub
2 changed files with 1 additions and 49 deletions

View File

@@ -86,18 +86,10 @@ module Spree
# Update the boolean _eligible_ attribute which determines which adjustments
# count towards the order's adjustment_total.
def set_eligibility
result = mandatory || (amount != 0 && eligible_for_originator?)
result = mandatory || amount != 0
update_column(:eligible, result)
end
# Allow originator of the adjustment to perform an additional eligibility of the adjustment
# Should return _true_ if originator is absent or doesn't implement _eligible?_
def eligible_for_originator?
return true if originator.nil?
!originator.respond_to?(:eligible?) || originator.eligible?(source)
end
# Update both the eligibility and amount of the adjustment. Adjustments
# delegate updating of amount to their Originator when present, but only if
# +locked+ is false. Adjustments that are +locked+ will never change their amount.

View File

@@ -78,20 +78,6 @@ module Spree
adjustment.set_eligibility
expect(adjustment).to be_eligible
end
it "should be eligible if not mandatory and eligible for the originator" do
adjustment.mandatory = false
allow(adjustment).to receive_messages(eligible_for_originator?: true)
adjustment.set_eligibility
expect(adjustment).to be_eligible
end
it "should not be eligible if not mandatory not eligible for the originator" do
adjustment.mandatory = false
allow(adjustment).to receive_messages(eligible_for_originator?: false)
adjustment.set_eligibility
expect(adjustment).to_not be_eligible
end
end
end
@@ -139,32 +125,6 @@ module Spree
end
end
context "#eligible_for_originator?" do
context "with no originator" do
specify { expect(adjustment).to be_eligible_for_originator }
end
context "with originator that doesn't have 'eligible?'" do
before { adjustment.originator = build(:tax_rate) }
specify { expect(adjustment).to be_eligible_for_originator }
end
context "with originator that has 'eligible?'" do
let(:originator) { Spree::TaxRate.new }
before { adjustment.originator = originator }
context "and originator is eligible for order" do
before { allow(originator).to receive_messages(eligible?: true) }
specify { expect(adjustment).to be_eligible_for_originator }
end
context "and originator is not eligible for order" do
before { allow(originator).to receive_messages(eligible?: false) }
specify { expect(adjustment).to_not be_eligible_for_originator }
end
end
end
context "#display_amount" do
before { adjustment.amount = 10.55 }