Skip to content

Commit

Permalink
Remove the banner from confirmation email if hide_ofn_navigation is true
Browse files Browse the repository at this point in the history
+ add specs that test for the presence of the footer logo which is in the header (I know ;))
  • Loading branch information
jibees committed May 15, 2023
1 parent a4e3eef commit 18683de
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
1 change: 1 addition & 0 deletions app/mailers/subscription_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
27 changes: 14 additions & 13 deletions app/views/layouts/mailer.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions spec/mailers/subscription_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)}\"" }

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 18683de

Please sign in to comment.