Rename fee adjustment clear-all method

This commit is contained in:
Matt-Yorkley
2021-01-28 01:25:36 +00:00
parent 9abf6cdcdf
commit 3ecdfca9cf
4 changed files with 10 additions and 10 deletions

View File

@@ -40,8 +40,8 @@ class EnterpriseFee < ActiveRecord::Base
joins(:calculator).where('spree_calculators.type IN (?)', PER_ORDER_CALCULATORS)
}
def self.clear_all_adjustments_on_order(order)
order.adjustments.where(originator_type: 'EnterpriseFee').destroy_all
def self.clear_all_adjustments(order)
order.adjustments.enterprise_fee.destroy_all
end
private

View File

@@ -667,7 +667,7 @@ module Spree
# See https://github.com/rails/rails/blob/3-2-stable/activerecord/lib/active_record/locking/pessimistic.rb#L69
# and https://www.postgresql.org/docs/current/static/sql-select.html#SQL-FOR-UPDATE-SHARE
with_lock do
EnterpriseFee.clear_all_adjustments_on_order self
EnterpriseFee.clear_all_adjustments self
fee_handler = OrderFeesHandler.new(self)
fee_handler.create_line_item_fees!

View File

@@ -110,7 +110,7 @@ describe EnterpriseFee do
order_cycle.exchanges[0].enterprise_fees[0].create_adjustment('foo4', line_item2.order, line_item2, true)
expect do
EnterpriseFee.clear_all_adjustments_on_order order
EnterpriseFee.clear_all_adjustments order
end.to change(order.adjustments, :count).by(-4)
end
@@ -121,7 +121,7 @@ describe EnterpriseFee do
enterprise_fee_aplicator.create_order_adjustment(order)
expect do
EnterpriseFee.clear_all_adjustments_on_order order
EnterpriseFee.clear_all_adjustments order
end.to change(order.adjustments, :count).by(-1)
end
@@ -135,7 +135,7 @@ describe EnterpriseFee do
label: 'hello' })
expect do
EnterpriseFee.clear_all_adjustments_on_order order
EnterpriseFee.clear_all_adjustments order
end.to change(order.adjustments, :count).by(0)
end
end

View File

@@ -541,7 +541,7 @@ describe Spree::Order do
end
it "clears all enterprise fee adjustments on the order" do
expect(EnterpriseFee).to receive(:clear_all_adjustments_on_order).with(subject)
expect(EnterpriseFee).to receive(:clear_all_adjustments).with(subject)
subject.recreate_all_fees!
end
@@ -552,7 +552,7 @@ describe Spree::Order do
end
it "skips order cycle per-order adjustments for orders that don't have an order cycle" do
allow(EnterpriseFee).to receive(:clear_all_adjustments_on_order)
allow(EnterpriseFee).to receive(:clear_all_adjustments)
allow(subject).to receive(:order_cycle) { nil }
@@ -560,7 +560,7 @@ describe Spree::Order do
end
it "ensures the correct adjustment(s) are created for order cycles" do
allow(EnterpriseFee).to receive(:clear_all_adjustments_on_order)
allow(EnterpriseFee).to receive(:clear_all_adjustments)
line_item = create(:line_item, order: subject)
allow(fee_handler).to receive(:provided_by_order_cycle?) { true }
@@ -575,7 +575,7 @@ describe Spree::Order do
end
it "ensures the correct per-order adjustment(s) are created for order cycles" do
allow(EnterpriseFee).to receive(:clear_all_adjustments_on_order)
allow(EnterpriseFee).to receive(:clear_all_adjustments)
order_cycle = double(:order_cycle)
expect_any_instance_of(OpenFoodNetwork::EnterpriseFeeCalculator).