From 18683de8a3bf91ff6d5af461dc90d157e2d98678 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Tue, 25 Apr 2023 10:29:08 +0200 Subject: [PATCH] Remove the banner from confirmation email if hide_ofn_navigation is true + add specs that test for the presence of the footer logo which is in the header (I know ;)) --- app/mailers/subscription_mailer.rb | 1 + app/views/layouts/mailer.html.haml | 27 ++++++++++++------------ spec/mailers/subscription_mailer_spec.rb | 14 ++++++++++++ 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/app/mailers/subscription_mailer.rb b/app/mailers/subscription_mailer.rb index 174fef790b1a..51000576c175 100644 --- a/app/mailers/subscription_mailer.rb +++ b/app/mailers/subscription_mailer.rb @@ -11,6 +11,7 @@ class SubscriptionMailer < ApplicationMailer def confirmation_email(order) @type = 'confirmation' @order = order + @hide_ofn_navigation = @order.distributor.hide_ofn_navigation send_mail(order) end diff --git a/app/views/layouts/mailer.html.haml b/app/views/layouts/mailer.html.haml index 0160dfd72764..f559f67d628d 100644 --- a/app/views/layouts/mailer.html.haml +++ b/app/views/layouts/mailer.html.haml @@ -7,19 +7,20 @@ = Spree::Config[:site_name] = stylesheet_pack_tag 'mail' %body{:bgcolor => "#FFFFFF" } - %table.head-wrap{:bgcolor => "#f2f2f2"} - %tr - %td - %td.header.container - .content - %table{:bgcolor => "#f2f2f2"} - %tr - %td - %img{src: ContentConfig.url_for(:footer_logo), width: "144", height: "50"}/ - %td{:align => "right"} - %h6.collapse - = Spree::Config[:site_name] - %td + - unless @hide_ofn_navigation + %table.head-wrap{:bgcolor => "#f2f2f2"} + %tr + %td + %td.header.container + .content + %table{:bgcolor => "#f2f2f2"} + %tr + %td + %img{src: ContentConfig.url_for(:footer_logo), width: "144", height: "50"}/ + %td{:align => "right"} + %h6.collapse + = Spree::Config[:site_name] + %td %table.body-wrap %tr diff --git a/spec/mailers/subscription_mailer_spec.rb b/spec/mailers/subscription_mailer_spec.rb index 0c4a85c6d94d..5ce3ad372031 100644 --- a/spec/mailers/subscription_mailer_spec.rb +++ b/spec/mailers/subscription_mailer_spec.rb @@ -117,6 +117,10 @@ expect(body).to include "This order was automatically placed for you" end + it "display the OFN header by default" do + expect(email.body).to include(ContentConfig.url_for(:footer_logo)) + end + describe "linking to order page" do let(:order_link_href) { "href=\"#{order_url(order)}\"" } @@ -152,6 +156,16 @@ expect(email.body).to include('NOT PAID') end end + + context 'when hide OFN navigation is enabled for the distributor of the order' do + before do + allow(order.distributor).to receive(:hide_ofn_navigation).and_return(true) + end + + it 'does not display the OFN navigation' do + expect(email.body).to_not include(ContentConfig.url_for(:footer_logo)) + end + end end describe "empty order notification" do