Files
openfoodnetwork/spec/support/shared_examples/email_header_examples.rb
Konrad 52ddb29dc7 Update user mailer specs to check that white labelling does not affect these emails
Move tests to separate file for reuse in other emails

Pass on :mail symbol and obtain the mail-object using public_send() to call it with different names
2025-12-29 12:18:54 +01:00

32 lines
1.1 KiB
Ruby

# frozen_string_literal: true
RSpec.shared_examples 'email with inactive white labelling' do |mail|
it 'always displays the OFN header with logo' do
expect(public_send(mail).body).to include(ContentConfig.url_for(:logo))
end
end
RSpec.shared_examples 'non-customer facing email with active white labelling' do |mail|
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 'still displays the OFN header with logo' do
expect(public_send(mail).body).to include(ContentConfig.url_for(:logo))
end
end
end
RSpec.shared_examples 'customer facing email with active white labelling' do |mail|
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 header and logo' do
expect(public_send(mail).body).not_to include(ContentConfig.url_for(:logo))
end
end
end