diff --git a/app/models/spree/adjustment.rb b/app/models/spree/adjustment.rb index eb970bc659..84a7f603de 100644 --- a/app/models/spree/adjustment.rb +++ b/app/models/spree/adjustment.rb @@ -87,16 +87,6 @@ module Spree localize_number :amount - # Update the boolean _eligible_ attribute which determines which adjustments - # count towards the order's adjustment_total. - def set_eligibility - result = mandatory || amount != 0 - update_columns( - eligible: result, - updated_at: Time.zone.now - ) - 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. @@ -119,7 +109,6 @@ module Spree # the order object. After calling a reload, the source is the Shipment. reload originator.update_adjustment(self, calculable || source) if originator.present? - set_eligibility end def currency diff --git a/spec/controllers/spree/admin/orders_controller_spec.rb b/spec/controllers/spree/admin/orders_controller_spec.rb index f9cae535e5..5bfb20acfd 100644 --- a/spec/controllers/spree/admin/orders_controller_spec.rb +++ b/spec/controllers/spree/admin/orders_controller_spec.rb @@ -24,6 +24,7 @@ describe Spree::Admin::OrdersController, type: :controller do :adjustment, adjustable: order, label: "invalid adjustment", + eligible: false, amount: 0 ) diff --git a/spec/helpers/admin/orders_helper_spec.rb b/spec/helpers/admin/orders_helper_spec.rb index 79c3273687..4556763d22 100644 --- a/spec/helpers/admin/orders_helper_spec.rb +++ b/spec/helpers/admin/orders_helper_spec.rb @@ -18,8 +18,9 @@ describe Admin::OrdersHelper, type: :helper do expect(helper.order_adjustments_for_display(order)).to eq [] end - it "filters zero tax rate adjustments" do - create(:adjustment, adjustable: order, amount: 0, originator_type: "Spree::TaxRate") + it "filters ineligible adjustments" do + create(:adjustment, adjustable: order, amount: 0, eligible: false, + originator_type: "Spree::TaxRate") expect(helper.order_adjustments_for_display(order)).to eq [] end diff --git a/spec/models/spree/adjustment_spec.rb b/spec/models/spree/adjustment_spec.rb index 58c4caa00d..332ff7c604 100644 --- a/spec/models/spree/adjustment_spec.rb +++ b/spec/models/spree/adjustment_spec.rb @@ -36,11 +36,6 @@ module Spree adjustment.update! end - it "should set the eligibility" do - expect(adjustment).to receive(:set_eligibility) - adjustment.update! - end - it "should ask the originator to update_adjustment" do expect(originator).to receive(:update_adjustment) adjustment.update! @@ -68,33 +63,6 @@ module Spree end end - context "#eligible? after #set_eligibility" do - context "when amount is 0" do - before { adjustment.amount = 0 } - it "should be eligible if mandatory?" do - adjustment.mandatory = true - adjustment.set_eligibility - expect(adjustment).to be_eligible - end - - it "should not be eligible unless mandatory?" do - adjustment.mandatory = false - adjustment.set_eligibility - expect(adjustment).to_not be_eligible - end - end - - context "when amount is greater than 0" do - before { adjustment.amount = 25.00 } - - it "should be eligible if mandatory?" do - adjustment.mandatory = true - adjustment.set_eligibility - expect(adjustment).to be_eligible - end - end - end - context "#save" do it "should call order#update!" do adjustment = Spree::Adjustment.new(