diff --git a/app/assets/stylesheets/mail/email.scss b/app/assets/stylesheets/mail/email.scss index a82ea6c9f9..7351c8767d 100644 --- a/app/assets/stylesheets/mail/email.scss +++ b/app/assets/stylesheets/mail/email.scss @@ -63,6 +63,12 @@ p.notice { margin-top: 20px; } +.powered-by-ofn { + background-color: #ebebeb; + padding: .5em; + text-align: center; +} + table.social { background-color: #ebebeb; diff --git a/app/helpers/mailer_helper.rb b/app/helpers/mailer_helper.rb new file mode 100644 index 0000000000..34708b8e0a --- /dev/null +++ b/app/helpers/mailer_helper.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module MailerHelper + def footer_ofn_link + ofn = I18n.t("shared.mailers.powered_by.open_food_network") + + if ContentConfig.footer_email.present? + mail_to ContentConfig.footer_email, ofn + else + link_to ofn, "https://www.openfoodnetwork.org" + end + end +end diff --git a/app/mailers/spree/order_mailer.rb b/app/mailers/spree/order_mailer.rb index b566f0878b..9fbed9f02b 100644 --- a/app/mailers/spree/order_mailer.rb +++ b/app/mailers/spree/order_mailer.rb @@ -6,6 +6,7 @@ module Spree helper SpreeCurrencyHelper helper Spree::Admin::PaymentsHelper helper OrderHelper + helper MailerHelper include I18nHelper def cancel_email(order_or_order_id, resend = false) diff --git a/app/mailers/subscription_mailer.rb b/app/mailers/subscription_mailer.rb index 18d68cb504..0f60ccbeab 100644 --- a/app/mailers/subscription_mailer.rb +++ b/app/mailers/subscription_mailer.rb @@ -1,5 +1,6 @@ class SubscriptionMailer < Spree::BaseMailer helper CheckoutHelper + helper MailerHelper helper ShopMailHelper helper OrderHelper helper Spree::Admin::PaymentsHelper diff --git a/app/views/shared/mailers/_powered_by.html.haml b/app/views/shared/mailers/_powered_by.html.haml new file mode 100644 index 0000000000..1d71037a9a --- /dev/null +++ b/app/views/shared/mailers/_powered_by.html.haml @@ -0,0 +1,2 @@ +%p.powered-by-ofn + = t(".powered_html", open_food_network: footer_ofn_link) diff --git a/app/views/spree/order_mailer/cancel_email.html.haml b/app/views/spree/order_mailer/cancel_email.html.haml index 0965d522b8..0c46511c3d 100755 --- a/app/views/spree/order_mailer/cancel_email.html.haml +++ b/app/views/spree/order_mailer/cancel_email.html.haml @@ -26,4 +26,4 @@ = t(".unpaid_order") = render 'signoff' -= render 'shared/mailers/social_and_contact' += render 'shared/mailers/powered_by' diff --git a/app/views/spree/order_mailer/confirm_email_for_customer.html.haml b/app/views/spree/order_mailer/confirm_email_for_customer.html.haml index 13ce27a8ee..42ed2d9cc1 100644 --- a/app/views/spree/order_mailer/confirm_email_for_customer.html.haml +++ b/app/views/spree/order_mailer/confirm_email_for_customer.html.haml @@ -25,4 +25,4 @@ = render 'shipping' = render 'special_instructions' = render 'signoff' -= render 'shared/mailers/social_and_contact' += render 'shared/mailers/powered_by' diff --git a/app/views/spree/user_mailer/confirmation_instructions.html.haml b/app/views/spree/user_mailer/confirmation_instructions.html.haml index 1085bced91..2a7852d94f 100644 --- a/app/views/spree/user_mailer/confirmation_instructions.html.haml +++ b/app/views/spree/user_mailer/confirmation_instructions.html.haml @@ -12,7 +12,7 @@ = render 'shared/mailers/signoff' -= render 'shared/mailers/social_and_contact' += render 'shared/mailers/powered_by' %p.notice = t :email_confirmation_notice_unexpected, sitename: @instance, contact: @contact diff --git a/app/views/subscription_mailer/confirmation_summary_email.html.haml b/app/views/subscription_mailer/confirmation_summary_email.html.haml index febfb2c6cf..861df53454 100644 --- a/app/views/subscription_mailer/confirmation_summary_email.html.haml +++ b/app/views/subscription_mailer/confirmation_summary_email.html.haml @@ -19,4 +19,4 @@ %p   = render 'shared/mailers/signoff' -= render 'shared/mailers/social_and_contact' += render 'shared/mailers/powered_by' diff --git a/app/views/subscription_mailer/placement_summary_email.html.haml b/app/views/subscription_mailer/placement_summary_email.html.haml index febfb2c6cf..861df53454 100644 --- a/app/views/subscription_mailer/placement_summary_email.html.haml +++ b/app/views/subscription_mailer/placement_summary_email.html.haml @@ -19,4 +19,4 @@ %p   = render 'shared/mailers/signoff' -= render 'shared/mailers/social_and_contact' += render 'shared/mailers/powered_by' diff --git a/config/locales/en.yml b/config/locales/en.yml index 41ce17bb63..d67f8eafd5 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1252,6 +1252,10 @@ en: hide_closed_shops: "Hide closed shops" show_on_map: "Show all on the map" shared: + mailers: + powered_by: + open_food_network: "Open Food Network" + powered_html: "Your shopping experience is powered by the %{open_food_network}." menu: cart: cart: "Cart" diff --git a/spec/mailers/order_mailer_spec.rb b/spec/mailers/order_mailer_spec.rb index 6129cf489c..084f7186e5 100644 --- a/spec/mailers/order_mailer_spec.rb +++ b/spec/mailers/order_mailer_spec.rb @@ -132,6 +132,19 @@ describe Spree::OrderMailer do Spree::OrderMailer.confirm_email_for_customer(order.id).deliver_now expect(ActionMailer::Base.deliveries.first.reply_to).to eq([distributor.contact.email]) end + + it "includes a link to the configured instance email address" do + mail = Spree::OrderMailer.confirm_email_for_customer(order.id) + + expect(mail.body.encoded).to include "mailto:hello@openfoodnetwork.org" + end + + it "includes a link to the OFN global website if no email address is available" do + expect(ContentConfig).to receive(:footer_email).and_return("") + mail = Spree::OrderMailer.confirm_email_for_customer(order.id) + + expect(mail.body.encoded).to include "https://www.openfoodnetwork.org" + end end describe "for shops" do