Update Admin::OrdersHelper#order_adjustments_for_display

This commit is contained in:
Matt-Yorkley
2021-02-27 12:40:01 +00:00
parent 21e0c36f4f
commit 5d1d72b36b
2 changed files with 6 additions and 5 deletions

View File

@@ -5,9 +5,9 @@ module Admin
# We exclude shipping method adjustments because they are displayed in a
# separate table together with the order line items.
def order_adjustments_for_display(order)
order.adjustments.eligible.reject do |adjustment|
adjustment.originator_type == "Spree::ShippingMethod"
end
order.all_adjustments.enterprise_fee +
order.all_adjustments.payment_fee.eligible +
order.adjustments.admin
end
end
end

View File

@@ -7,13 +7,14 @@ describe Admin::OrdersHelper, type: :helper do
let(:order) { create(:order) }
it "selects eligible adjustments" do
adjustment = create(:adjustment, order: order, adjustable: order, amount: 1)
adjustment = create(:adjustment, order: order, adjustable: order, amount: 1, source: nil)
expect(helper.order_adjustments_for_display(order)).to eq [adjustment]
end
it "filters shipping method adjustments" do
create(:adjustment, order: order, adjustable: order, amount: 1, originator_type: "Spree::ShippingMethod")
create(:adjustment, order: order, adjustable: order, amount: 1,
originator_type: "Spree::ShippingMethod")
expect(helper.order_adjustments_for_display(order)).to eq []
end