mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Test order links in subscription placement emails
This commit is contained in:
@@ -6,7 +6,9 @@ describe SubscriptionMailer do
|
||||
let!(:mail_method) { create(:mail_method, preferred_mails_from: 'spree@example.com') }
|
||||
|
||||
describe "order placement" do
|
||||
let(:subscription) { create(:subscription, with_items: true) }
|
||||
let(:shop) { create(:enterprise) }
|
||||
let(:customer) { create(:customer, enterprise: shop) }
|
||||
let(:subscription) { create(:subscription, shop: shop, customer: customer, with_items: true) }
|
||||
let(:proxy_order) { create(:proxy_order, subscription: subscription) }
|
||||
let!(:order) { proxy_order.initialise_order! }
|
||||
|
||||
@@ -24,7 +26,6 @@ describe SubscriptionMailer do
|
||||
body = SubscriptionMailer.deliveries.last.body.encoded
|
||||
expect(body).to include "This order was automatically created for you."
|
||||
expect(body).to include "Unfortunately, not all products that you requested were available."
|
||||
expect(body).to include "href=\"#{spree.order_url(order)}\""
|
||||
end
|
||||
end
|
||||
|
||||
@@ -39,7 +40,36 @@ describe SubscriptionMailer do
|
||||
body = SubscriptionMailer.deliveries.last.body.encoded
|
||||
expect(body).to include "This order was automatically created for you."
|
||||
expect(body).to_not include "Unfortunately, not all products that you requested were available."
|
||||
expect(body).to include "href=\"#{spree.order_url(order)}\""
|
||||
end
|
||||
end
|
||||
|
||||
describe "linking to order page" do
|
||||
let(:order_link_href) { "href=\"#{spree.order_url(order)}\"" }
|
||||
let(:order_link_style) { "style='[^']+'" }
|
||||
|
||||
let(:shop) { create(:enterprise, allow_order_changes: true) }
|
||||
|
||||
let(:email) { SubscriptionMailer.deliveries.last }
|
||||
let(:body) { email.body.encoded }
|
||||
|
||||
before do
|
||||
SubscriptionMailer.placement_email(order, {}).deliver
|
||||
end
|
||||
|
||||
let(:customer) { create(:customer, enterprise: shop) }
|
||||
|
||||
it "provides link to make changes" do
|
||||
expect(body).to match /<a #{order_link_href} #{order_link_style}>make changes<\/a>/
|
||||
expect(body).to_not match /<a #{order_link_href} #{order_link_style}>view details of this order<\/a>/
|
||||
end
|
||||
|
||||
context "when the distributor does not allow changes to the order" do
|
||||
let(:shop) { create(:enterprise, allow_order_changes: false) }
|
||||
|
||||
it "provides link to view details" do
|
||||
expect(body).to_not match /<a #{order_link_href} #{order_link_style}>make changes<\/a>/
|
||||
expect(body).to match /<a #{order_link_href} #{order_link_style}>view details of this order<\/a>/
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user