Custom subscription placement email if non-user

The order link should not be provided if the order does not have an
associated user account.
This commit is contained in:
Kristina Lim
2018-08-30 03:02:42 +08:00
parent ad8b120e48
commit f8244a400a
3 changed files with 40 additions and 14 deletions

View File

@@ -56,19 +56,37 @@ describe SubscriptionMailer do
SubscriptionMailer.placement_email(order, {}).deliver
end
let(:customer) { create(:customer, enterprise: shop) }
context "when the customer has a user account" do
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>/
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
context "when the distributor does not allow changes to the order" do
let(:shop) { create(:enterprise, allow_order_changes: false) }
context "when the customer has no user account" do
let(:customer) { create(:customer, enterprise: shop, user: nil) }
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>/
it "does not provide link" do
expect(body).to_not match /#{order_link_href}/
end
context "when the distributor does not allow changes to the order" do
let(:shop) { create(:enterprise, allow_order_changes: false) }
it "does not provide link" do
expect(body).to_not match /#{order_link_href}/
end
end
end
end