From fa459c039501a151d90274b4f2b9461365dcf644 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Tue, 20 Aug 2013 14:25:18 +1000 Subject: [PATCH] Summarise distribution charges: order confirm page and email --- .../summarise_distribution_charges.html.haml.deface | 8 ++++++++ .../confirm_email_with_distributor_info.text.erb | 2 +- .../engine.rb | 2 ++ spec/features/consumer/checkout_spec.rb | 10 ++++++++-- 4 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 app/overrides/spree/shared/_order_details/summarise_distribution_charges.html.haml.deface diff --git a/app/overrides/spree/shared/_order_details/summarise_distribution_charges.html.haml.deface b/app/overrides/spree/shared/_order_details/summarise_distribution_charges.html.haml.deface new file mode 100644 index 0000000000..c4e7ed5dfd --- /dev/null +++ b/app/overrides/spree/shared/_order_details/summarise_distribution_charges.html.haml.deface @@ -0,0 +1,8 @@ +/ replace_contents 'tfoot#order-charges' + +- checkout_adjustments_for_summary(@order).each do |adjustment| + %tr.total + %td{:colspan => "4"} + %strong= adjustment.label + %td.total + %span= adjustment.display_amount.to_html diff --git a/lib/chili/enterprises_distributor_info_rich_text_feature/app/views/spree/order_mailer/confirm_email_with_distributor_info.text.erb b/lib/chili/enterprises_distributor_info_rich_text_feature/app/views/spree/order_mailer/confirm_email_with_distributor_info.text.erb index aa3b59de8c..10dc7ace3b 100644 --- a/lib/chili/enterprises_distributor_info_rich_text_feature/app/views/spree/order_mailer/confirm_email_with_distributor_info.text.erb +++ b/lib/chili/enterprises_distributor_info_rich_text_feature/app/views/spree/order_mailer/confirm_email_with_distributor_info.text.erb @@ -11,7 +11,7 @@ Order for: <%= @order.bill_address.full_name %> <% end %> ============================================================ Subtotal: <%= @order.display_item_total %> -<% @order.adjustments.eligible.each do |adjustment| %> +<% checkout_adjustments_for_summary(@order).each do |adjustment| %> <%= raw(adjustment.label) %> <%= adjustment.display_amount %> <% end %> Order Total: <%= @order.display_total %> diff --git a/lib/chili/enterprises_distributor_info_rich_text_feature/lib/enterprises_distributor_info_rich_text_feature/engine.rb b/lib/chili/enterprises_distributor_info_rich_text_feature/lib/enterprises_distributor_info_rich_text_feature/engine.rb index 36a13fe94a..538c64e30e 100644 --- a/lib/chili/enterprises_distributor_info_rich_text_feature/lib/enterprises_distributor_info_rich_text_feature/engine.rb +++ b/lib/chili/enterprises_distributor_info_rich_text_feature/lib/enterprises_distributor_info_rich_text_feature/engine.rb @@ -7,6 +7,8 @@ module EnterprisesDistributorInfoRichTextFeature initializer 'enterprises_distributor_info_rich_text_feature.mailer', :after => :load_config_initializers do |app| if OpenFoodWeb::FeatureToggle.enabled? :enterprises_distributor_info_rich_text ::Spree::OrderMailer.class_eval do + helper CheckoutHelper + def confirm_email(order, resend = false) find_order(order) subject = (resend ? "[#{t(:resend).upcase}] " : '') diff --git a/spec/features/consumer/checkout_spec.rb b/spec/features/consumer/checkout_spec.rb index 562ea7ad36..1fbb895a80 100644 --- a/spec/features/consumer/checkout_spec.rb +++ b/spec/features/consumer/checkout_spec.rb @@ -324,13 +324,19 @@ feature %q{ click_checkout_continue_button # -- Checkout: Order complete - page.should have_content('Your order has been processed successfully') - page.should have_content(@payment_method_all.description) + page.should have_content 'Your order has been processed successfully' + page.should have_content @payment_method_all.description + page.should have_selector 'tfoot#order-charges tr.total td', text: 'Distribution' + page.should have_selector 'tfoot#order-charges tr.total td', text: '$3.00' # page.should have_content('Your order will be available on:') # page.should have_content('On Tuesday, 4 PM') # page.should have_content('12 Bungee Rd, Carion') + + # -- Checkout: Email + email = ActionMailer::Base.deliveries.last + email.body.should =~ /Distribution \$3.00/ end