From 0029a1b6cf38f9215e18b0f0d9eb20d03b07efe7 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Thu, 27 Apr 2017 12:41:12 +1000 Subject: [PATCH] Ensure order adjustments are displayed in edit form for customers --- app/views/spree/orders/_form.html.haml | 8 ++++++++ spec/features/consumer/shopping/orders_spec.rb | 10 +++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/views/spree/orders/_form.html.haml b/app/views/spree/orders/_form.html.haml index e7d5f69f72..7cb5c0f9bf 100644 --- a/app/views/spree/orders/_form.html.haml +++ b/app/views/spree/orders/_form.html.haml @@ -43,6 +43,14 @@ %span.order-total.distribution-total= display_checkout_admin_and_handling_adjustments_total_for(@order) %td + - checkout_adjustments_for(@order, exclude: [:line_item]).reject{ |a| a.amount == 0 }.reverse_each do |adjustment| + %tr.order-adjustment + %td.text-right{:colspan => "3"} + = adjustment.label + %td.text-right.total + %span= adjustment.display_amount.to_html + %td + %tr %td.text-right{colspan:"3"} %h5 diff --git a/spec/features/consumer/shopping/orders_spec.rb b/spec/features/consumer/shopping/orders_spec.rb index 8a55439441..f5962a232a 100644 --- a/spec/features/consumer/shopping/orders_spec.rb +++ b/spec/features/consumer/shopping/orders_spec.rb @@ -8,13 +8,15 @@ feature "Order Management", js: true do let(:user) { create(:user, bill_address: address, ship_address: address) } let(:distributor) { create(:distributor_enterprise, with_payment_and_shipping: true, charges_sales_tax: true) } let(:order_cycle) { create(:order_cycle) } + let(:shipping_method) { distributor.shipping_methods.first } let(:order) { create(:completed_order_with_totals, order_cycle: order_cycle, distributor: distributor, user: user, bill_address: address, ship_address: address) } let!(:item1) { order.reload.line_items.first } let!(:item2) { create(:line_item, order: order) } let!(:item3) { create(:line_item, order: order) } before do - order.update_attributes(shipping_method_id: distributor.shipping_methods.first.id) + shipping_method.calculator.update_attributes(preferred_amount: 5.0) + order.update_attributes(shipping_method_id: shipping_method.id) order.reload.save quick_login_as user end @@ -49,10 +51,12 @@ feature "Order Management", js: true do end expect(find("tr.variant-#{item2.variant.id}")).to have_content item2.product.name expect(find("tr.variant-#{item3.variant.id}")).to have_content item3.product.name + expect(find("tr.order-adjustment")).to have_content "Shipping" + expect(find("tr.order-adjustment")).to have_content "$5.00" click_button I18n.t(:save_changes) - expect(find(".order-total.grand-total")).to have_content "$40.00" + expect(find(".order-total.grand-total")).to have_content "$45.00" expect(item1.reload.quantity).to eq 2 # Deleting an item @@ -60,7 +64,7 @@ feature "Order Management", js: true do click_link "delete_line_item_#{item2.id}" end - expect(find(".order-total.grand-total")).to have_content "$30.00" + expect(find(".order-total.grand-total")).to have_content "$35.00" expect(Spree::LineItem.find_by_id(item2.id)).to be nil # Cancelling the order