From fb93351386383facc1a13cfdfad5e0bc75d461cf Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Wed, 30 May 2018 12:48:25 +1000 Subject: [PATCH] Show fee breakdown in line items panel if present --- .../_subscription_line_items.html.haml | 11 ++++++++++- spec/features/admin/subscriptions_spec.rb | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/app/views/admin/subscriptions/_subscription_line_items.html.haml b/app/views/admin/subscriptions/_subscription_line_items.html.haml index dcfd0c5fe0..0ef917dd3d 100644 --- a/app/views/admin/subscriptions/_subscription_line_items.html.haml +++ b/app/views/admin/subscriptions/_subscription_line_items.html.haml @@ -29,7 +29,16 @@ = t(:subtotal) \: %td.total.align-center - %span {{ subscription.estimatedSubtotal() | currency }} + %span#order_subtotal {{ subscription.estimatedSubtotal() | currency }} + %td.actions + %tbody#fees.no-border-top{ ng: { show: "subscription.estimatedFees() > 0" } } + %tr#fees-row + %td{:colspan => "3"} + %b + = t(:fees) + \: + %td.total.align-center + %span#order_fees {{ subscription.estimatedFees() | currency }} %td.actions %tbody#order-total.grand-total.no-border-top{"data-hook" => "admin_order_form_total"} %tr diff --git a/spec/features/admin/subscriptions_spec.rb b/spec/features/admin/subscriptions_spec.rb index 556164386a..ccdac62aef 100644 --- a/spec/features/admin/subscriptions_spec.rb +++ b/spec/features/admin/subscriptions_spec.rb @@ -17,6 +17,13 @@ feature 'Subscriptions' do let!(:subscription2) { create(:subscription, shop: shop2, with_items: true, with_proxy_orders: true) } let!(:subscription_unmanaged) { create(:subscription, shop: shop_unmanaged, with_items: true, with_proxy_orders: true) } + before do + subscription.update_attributes(shipping_fee_estimate: 3.5) + subscription.subscription_line_items.each do |sli| + sli.update_attributes(price_estimate: 5) + end + end + it "passes the smoke test" do visit spree.admin_path click_link 'Orders' @@ -60,6 +67,18 @@ feature 'Subscriptions' do expect(page).to_not have_selector "th.customer" expect(page).to_not have_content subscription.customer.email + # Viewing Products + within "tr#so_#{subscription.id}" do + expect(page).to have_selector "td.items.panel-toggle", text: 3 + page.find("td.items.panel-toggle").trigger('click') + end + + within "#subscription-line-items" do + expect(page).to have_selector "span#order_subtotal", text: "$15.00" # 3 x $5 items + expect(page).to have_selector "span#order_fees", text: "$3.50" # $3.5 shipping + expect(page).to have_selector "span#order_form_total", text: "$18.50" # 3 x $5 items + $3.5 shipping + end + # Viewing Orders within "tr#so_#{subscription.id}" do expect(page).to have_selector "td.orders.panel-toggle", text: 1