diff --git a/app/models/spree/adjustment.rb b/app/models/spree/adjustment.rb index 8d398860fc..cb965b8aef 100644 --- a/app/models/spree/adjustment.rb +++ b/app/models/spree/adjustment.rb @@ -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. diff --git a/spec/models/spree/adjustment_spec.rb b/spec/models/spree/adjustment_spec.rb index 344fb8a17f..1f77bd725b 100644 --- a/spec/models/spree/adjustment_spec.rb +++ b/spec/models/spree/adjustment_spec.rb @@ -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 }