Fixing some breaking bugs in the refactored mailer

This commit is contained in:
Will Marshall
2013-12-13 15:38:27 +11:00
parent f6af9e78ac
commit 63349c7c9a
5 changed files with 16 additions and 9 deletions

View File

@@ -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

View File

@@ -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 %>

View File

@@ -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

View File

@@ -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

View File

@@ -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