mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
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:
@@ -3,11 +3,18 @@
|
||||
|
||||
%p.callout
|
||||
= t("email_so_placement_explainer_html")
|
||||
- allow_changes = !!@order.distributor.allow_order_changes?
|
||||
= t("email_so_edit_#{allow_changes}_html",
|
||||
orders_close_at: l(@order.order_cycle.orders_close_at, format: mail_long_datetime_format),
|
||||
order_url: spree.order_url(@order))
|
||||
= t("email_so_contact_distributor_html", distributor: @order.distributor.name, email: @order.distributor.contact.email)
|
||||
|
||||
- if @order.user.present?
|
||||
- allow_changes = !!@order.distributor.allow_order_changes?
|
||||
= t("email_so_edit_#{allow_changes}_html",
|
||||
orders_close_at: l(@order.order_cycle.orders_close_at, format: mail_long_datetime_format),
|
||||
order_url: spree.order_url(@order))
|
||||
= t("email_so_contact_distributor_html", distributor: @order.distributor.name, email: @order.distributor.contact.email)
|
||||
- else
|
||||
= t("email_so_contact_distributor_to_change_order_html",
|
||||
orders_close_at: l(@order.order_cycle.orders_close_at, format: mail_long_datetime_format),
|
||||
distributor: @order.distributor.name,
|
||||
email: @order.distributor.contact.email)
|
||||
|
||||
%p
|
||||
%h4
|
||||
|
||||
@@ -1461,6 +1461,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using
|
||||
email_so_edit_true_html: "You can <a href='%{order_url}'>make changes</a> until orders close on %{orders_close_at}."
|
||||
email_so_edit_false_html: "You can <a href='%{order_url}'>view details of this order</a> at any time."
|
||||
email_so_contact_distributor_html: "If you have any questions you can contact <strong>%{distributor}</strong> via %{email}."
|
||||
email_so_contact_distributor_to_change_order_html: "This order was automatically created for you. You can make changes until orders close on %{orders_close_at} by contacting <strong>%{distributor}</strong> via %{email}."
|
||||
email_so_confirmation_intro_html: "Your order with <strong>%{distributor}</strong> is now confirmed"
|
||||
email_so_confirmation_explainer_html: "This order was automatically placed for you, and it has now been finalised."
|
||||
email_so_confirmation_details_html: "Here's everything you need to know about your order from <strong>%{distributor}</strong>:"
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user