diff --git a/app/mailers/spree/order_mailer_decorator.rb b/app/mailers/spree/order_mailer_decorator.rb index f95912b591..03f9fcdfaf 100644 --- a/app/mailers/spree/order_mailer_decorator.rb +++ b/app/mailers/spree/order_mailer_decorator.rb @@ -6,7 +6,7 @@ Spree::OrderMailer.class_eval do subject = (resend ? "[#{t(:resend).upcase}] " : '') subject += "#{Spree::Config[:site_name]} #{t('order_mailer.confirm_email.subject')} ##{@order.number}" mail(:to => @order.email, - :from => order.distributor.email || from_address, + :from => @order.distributor.email || from_address, :subject => subject, :cc => "orders@openfoodnetwork.org") end diff --git a/app/views/spree/order_mailer/confirm_email.text.erb b/app/views/spree/order_mailer/confirm_email.text.erb index 34356401cd..e72fe48433 100644 --- a/app/views/spree/order_mailer/confirm_email.text.erb +++ b/app/views/spree/order_mailer/confirm_email.text.erb @@ -12,7 +12,7 @@ Order for: <%= @order.bill_address.full_name %> ============================================================ Subtotal: <%= @order.display_item_total %> <% checkout_adjustments_for_summary(@order).each do |adjustment| %> - <%= raw(adjustment.label) %> <%= adjustment.display_amount %> + <%= raw(adjustment.label) %> <%= adjustment.display_amount %> <% end %> Order Total: <%= @order.display_total %> diff --git a/spec/features/chili/enterprises_distributor_info_rich_text_feature_spec.rb b/spec/features/chili/enterprises_distributor_info_rich_text_feature_spec.rb index b0c985d423..a8c6c6c541 100644 --- a/spec/features/chili/enterprises_distributor_info_rich_text_feature_spec.rb +++ b/spec/features/chili/enterprises_distributor_info_rich_text_feature_spec.rb @@ -10,9 +10,16 @@ feature "enterprises distributor info as rich text" do enterprises_distributor_info_rich_text: true}) + ActionMailer::Base.delivery_method = :test + ActionMailer::Base.perform_deliveries = true + ActionMailer::Base.deliveries = [] # The deployment is not set to local_organics on Rails init, so these + # # initializers won't run. Re-call them now that the deployment is set. - EnterprisesDistributorInfoRichTextFeature::Engine.initializers.each &:run + end + + after do + ActionMailer::Base.deliveries.clear end diff --git a/spec/features/consumer/checkout_spec.rb b/spec/features/consumer/checkout_spec.rb index 3585ff6864..df4ea5500b 100644 --- a/spec/features/consumer/checkout_spec.rb +++ b/spec/features/consumer/checkout_spec.rb @@ -348,7 +348,7 @@ feature %q{ # -- Checkout: Email email = ActionMailer::Base.deliveries.last - email.body.should =~ /Distribution \$12.00/ + email.body.should =~ /Distribution[\s+]\$12.00/ end scenario "buying a product from an order cycle", :js => true do @@ -414,7 +414,7 @@ feature %q{ # -- Checkout: Email email = ActionMailer::Base.deliveries.last - email.body.should =~ /Distribution \$54.00/ + email.body.should =~ /Distribution[\s+]\$54.00/ end scenario "when I have past orders, it fills in my address", :js => true do @@ -497,7 +497,7 @@ feature %q{ # -- Checkout: Email email = ActionMailer::Base.deliveries.last - email.body.should =~ /Distribution \$54.00/ + email.body.should =~ /Distribution[\s+]\$54.00/ end diff --git a/spec/mailers/order_mailer_spec.rb b/spec/mailers/order_mailer_spec.rb index 383327f53b..3a8659cc0f 100644 --- a/spec/mailers/order_mailer_spec.rb +++ b/spec/mailers/order_mailer_spec.rb @@ -20,17 +20,17 @@ describe Spree::OrderMailer do end it "should send an email when given an order" do - Spree::OrderMailer.confirm_email(@order1).deliver + Spree::OrderMailer.confirm_email(@order1.id).deliver ActionMailer::Base.deliveries.count.should == 1 end it "should send the email from the enterprise email" do - Spree::OrderMailer.confirm_email(@order1).deliver + Spree::OrderMailer.confirm_email(@order1.id).deliver ActionMailer::Base.deliveries.first.from.should == [@distributor.email] end it "should cc orders" do - Spree::OrderMailer.confirm_email(@order1).deliver + Spree::OrderMailer.confirm_email(@order1.id).deliver ActionMailer::Base.deliveries.first.cc.should == ["orders@openfoodnetwork.org"] end end