mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-11 23:17:48 +00:00
Run transpec for spec/mailers
This commit is contained in:
@@ -27,28 +27,28 @@ describe Spree::OrderMailer do
|
||||
describe "for customers" do
|
||||
it "should send an email to the customer when given an order" do
|
||||
Spree::OrderMailer.confirm_email_for_customer(@order1.id).deliver
|
||||
ActionMailer::Base.deliveries.count.should == 1
|
||||
ActionMailer::Base.deliveries.first.to.should == [@order1.email]
|
||||
expect(ActionMailer::Base.deliveries.count).to eq(1)
|
||||
expect(ActionMailer::Base.deliveries.first.to).to eq([@order1.email])
|
||||
end
|
||||
|
||||
it "sets a reply-to of the enterprise email" do
|
||||
Spree::OrderMailer.confirm_email_for_customer(@order1.id).deliver
|
||||
ActionMailer::Base.deliveries.first.reply_to.should == [@distributor.contact.email]
|
||||
expect(ActionMailer::Base.deliveries.first.reply_to).to eq([@distributor.contact.email])
|
||||
end
|
||||
end
|
||||
|
||||
describe "for shops" do
|
||||
it "sends an email to the shop owner when given an order" do
|
||||
Spree::OrderMailer.confirm_email_for_shop(@order1.id).deliver
|
||||
ActionMailer::Base.deliveries.count.should == 1
|
||||
ActionMailer::Base.deliveries.first.to.should == [@distributor.contact.email]
|
||||
expect(ActionMailer::Base.deliveries.count).to eq(1)
|
||||
expect(ActionMailer::Base.deliveries.first.to).to eq([@distributor.contact.email])
|
||||
end
|
||||
|
||||
it "sends an email even if a footer_email is given" do
|
||||
# Testing bug introduced by a9c37c162e1956028704fbdf74ce1c56c5b3ce7d
|
||||
ContentConfig.footer_email = "email@example.com"
|
||||
Spree::OrderMailer.confirm_email_for_shop(@order1.id).deliver
|
||||
ActionMailer::Base.deliveries.count.should == 1
|
||||
expect(ActionMailer::Base.deliveries.count).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -50,7 +50,7 @@ describe ProducerMailer, type: :mailer do
|
||||
let(:mail) { ProducerMailer.order_cycle_report(s1, order_cycle) }
|
||||
|
||||
it "should send an email when an order cycle is closed" do
|
||||
ActionMailer::Base.deliveries.count.should == 1
|
||||
expect(ActionMailer::Base.deliveries.count).to eq(1)
|
||||
end
|
||||
|
||||
it "sets a reply-to of the oc coordinator's email" do
|
||||
@@ -58,7 +58,7 @@ describe ProducerMailer, type: :mailer do
|
||||
end
|
||||
|
||||
it "includes receival instructions" do
|
||||
mail.body.encoded.should include 'Outside shed.'
|
||||
expect(mail.body.encoded).to include 'Outside shed.'
|
||||
end
|
||||
|
||||
it "cc's the oc coordinator" do
|
||||
@@ -68,32 +68,32 @@ describe ProducerMailer, type: :mailer do
|
||||
it "contains an aggregated list of produce in alphabetical order" do
|
||||
expect(mail.body.encoded).to match(/coffee.+\n.+Zebra/)
|
||||
body_lines_including(mail, p1.name).each do |line|
|
||||
line.should include 'QTY: 3'
|
||||
line.should include '@ $10.00 = $30.00'
|
||||
expect(line).to include 'QTY: 3'
|
||||
expect(line).to include '@ $10.00 = $30.00'
|
||||
end
|
||||
body_as_html(mail).find("table.order-summary tr", text: p1.name)
|
||||
.should have_selector("td", text: "$30.00")
|
||||
expect(body_as_html(mail).find("table.order-summary tr", text: p1.name))
|
||||
.to have_selector("td", text: "$30.00")
|
||||
end
|
||||
|
||||
|
||||
it "displays tax totals for each product" do
|
||||
# Tax for p1 line items
|
||||
body_as_html(mail).find("table.order-summary tr", text: p1.name)
|
||||
.should have_selector("td.tax", text: "$2.73")
|
||||
expect(body_as_html(mail).find("table.order-summary tr", text: p1.name))
|
||||
.to have_selector("td.tax", text: "$2.73")
|
||||
end
|
||||
|
||||
it "does not include incomplete orders" do
|
||||
mail.body.encoded.should_not include p3.name
|
||||
expect(mail.body.encoded).not_to include p3.name
|
||||
end
|
||||
|
||||
it "does not include canceled orders" do
|
||||
mail.body.encoded.should_not include p5.name
|
||||
expect(mail.body.encoded).not_to include p5.name
|
||||
end
|
||||
|
||||
it "includes the total" do
|
||||
mail.body.encoded.should include 'Total: $50.00'
|
||||
body_as_html(mail).find("tr.total-row")
|
||||
.should have_selector("td", text: "$50.00")
|
||||
expect(mail.body.encoded).to include 'Total: $50.00'
|
||||
expect(body_as_html(mail).find("tr.total-row"))
|
||||
.to have_selector("td", text: "$50.00")
|
||||
end
|
||||
|
||||
it "sends no mail when the producer has no orders" do
|
||||
|
||||
Reference in New Issue
Block a user