Render only eligible adjustments on the order page

https://github.com/openfoodfoundation/openfoodnetwork/issues/3477

The admin orders edit form was displaying adjustments even if they were
"not eligible". For example, an additional fee with amount `0` is not
eligible. They were already hidden in the adjustments view and we are
hiding them in reports.
This commit is contained in:
Maikel Linke
2019-03-29 18:16:55 +11:00
parent 7348987567
commit 5760aed6a6
2 changed files with 14 additions and 1 deletions

View File

@@ -5,7 +5,7 @@
= render :partial => "spree/admin/orders/shipment", :collection => @order.shipments, :locals => { :order => order }
= render :partial => "spree/admin/orders/_form/adjustments", :locals => { :adjustments => @order.price_adjustments, :order => order, :title => Spree.t(:line_item_adjustments)}
= render :partial => "spree/admin/orders/_form/adjustments", :locals => { :adjustments => @order.adjustments, :order => order, :title => Spree.t(:order_adjustments)}
= render :partial => "spree/admin/orders/_form/adjustments", :locals => { :adjustments => @order.adjustments.eligible, :order => order, :title => Spree.t(:order_adjustments)}
- if order.line_items.exists?
%fieldset#order-total.no-border-bottom{"data-hook" => "order_details_total"}

View File

@@ -283,6 +283,19 @@ feature %q{
end
end
scenario "shows only eligible adjustments" do
adjustment = create(
:adjustment,
adjustable: @order,
label: "invalid adjustment",
amount: 0
)
visit spree.edit_admin_order_path(@order)
expect(page).to have_no_content adjustment.label
end
scenario "cannot split the order in different stock locations" do
# There's only 1 stock location in OFN, so the split functionality that comes with spree should be hidden
expect(page).to_not have_selector '.split-item'