From f068cb3cd7217001ef18cd1ffef3f9c53e473658 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Fri, 6 Jun 2014 17:05:50 +1000 Subject: [PATCH] Show shipping method via angular only (don't show spree's adjustment) --- app/helpers/checkout_helper.rb | 4 +++- app/views/checkout/_summary.html.haml | 2 +- spec/features/consumer/shopping/checkout_spec.rb | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/helpers/checkout_helper.rb b/app/helpers/checkout_helper.rb index 32e25bdfc5..e5e721454a 100644 --- a/app/helpers/checkout_helper.rb +++ b/app/helpers/checkout_helper.rb @@ -1,8 +1,10 @@ module CheckoutHelper - def checkout_adjustments_for_summary(order) + def checkout_adjustments_for_summary(order, opts={}) adjustments = order.adjustments.eligible + # Remove empty tax adjustments and (optionally) shipping fees adjustments.reject! { |a| a.originator_type == 'Spree::TaxRate' && a.amount == 0 } + adjustments.reject! { |a| a.originator_type == 'Spree::ShippingMethod' } if opts[:exclude_shipping] enterprise_fee_adjustments = adjustments.select { |a| a.originator_type == 'EnterpriseFee' } adjustments.reject! { |a| a.originator_type == 'EnterpriseFee' } diff --git a/app/views/checkout/_summary.html.haml b/app/views/checkout/_summary.html.haml index c943964a9f..47f9239839 100644 --- a/app/views/checkout/_summary.html.haml +++ b/app/views/checkout/_summary.html.haml @@ -7,7 +7,7 @@ %th Produce %td= current_order.display_item_total - - checkout_adjustments_for_summary(current_order).each do |adjustment| + - checkout_adjustments_for_summary(current_order, exclude_shipping: true).each do |adjustment| %tr %th= adjustment.label %td= adjustment.display_amount.to_html diff --git a/spec/features/consumer/shopping/checkout_spec.rb b/spec/features/consumer/shopping/checkout_spec.rb index fddda4e199..8b0efea314 100644 --- a/spec/features/consumer/shopping/checkout_spec.rb +++ b/spec/features/consumer/shopping/checkout_spec.rb @@ -146,6 +146,21 @@ feature "As a consumer I want to check out my cart", js: true do place_order page.should have_content "Your order has been processed successfully" end + + it "shows the payment processing failed message when submitted with an invalid credit card" do + toggle_payment + fill_in 'Card Number', with: "9999999988887777" + select 'February', from: 'secrets.card_month' + select (Date.today.year+1).to_s, from: 'secrets.card_year' + fill_in 'Security Code', with: '123' + + place_order + page.should have_content "Payment could not be processed, please check the details you entered" + + # Does not show duplicate shipping fee + visit checkout_path + page.all("th", text: "Shipping").count.should == 1 + end end end end