Commit cd6aac17 authored by Nicolas Dular's avatar Nicolas Dular

Fix call on nil for in-product marketing email

This fixes an issue with the in-product marketing emails, where we
called `.html_safe` on the second body line, which can be `nil`.

It also fixes a deprecation warning for the `inline_image_link` where
`options` was passed as a keyword argument.
parent 3c0902c7
......@@ -343,7 +343,7 @@ module InProductMarketingHelper
end
end
def inline_image_link(folder, image, **options)
def inline_image_link(folder, image, options)
attachments.inline[image] = File.read(Rails.root.join("app/assets/images", folder, image))
image_tag attachments[image].url, **options
end
......
......@@ -177,8 +177,9 @@
%td{ style: "padding: 10px 20px 30px 20px; font-family: 'Source Sans Pro', helvetica, arial, sans-serif; color:#000000; font-size: 18px; line-height: 24px;" }
%p{ style: "margin: 0 0 20px 0;" }
= in_product_marketing_body_line1(@track, @series, format: :html).html_safe
%p{ style: "margin: 0 0 20px 0;" }
= in_product_marketing_body_line2(@track, @series, format: :html).html_safe
- in_product_marketing_body_line2(@track, @series, format: :html)&.tap do |line|
%p{ style: "margin: 0 0 20px 0;" }
= line.html_safe
%tr
%td{ align: "center", style: "padding: 10px 20px 80px 20px; font-family: 'Source Sans Pro', helvetica, arial, sans-serif;" }
.cta_link= cta_link(@track, @series, @group, format: :html)
......
# frozen_string_literal: true
require 'spec_helper'
require 'email_spec'
RSpec.describe Emails::InProductMarketing do
include EmailSpec::Matchers
include InProductMarketingHelper
let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group) }
describe '#in_product_marketing_email' do
using RSpec::Parameterized::TableSyntax
where(:track, :series) do
:create | 0
:create | 1
:create | 2
:verify | 0
:verify | 1
:verify | 2
:trial | 0
:trial | 1
:trial | 2
:team | 0
:team | 1
:team | 2
end
with_them do
subject { Notify.in_product_marketing_email(user.id, group.id, track, series) }
it 'has the correct subject and content' do
aggregate_failures do
is_expected.to have_subject(subject_line(track, series))
is_expected.to have_body_text(in_product_marketing_title(track, series))
is_expected.to have_body_text(in_product_marketing_subtitle(track, series))
is_expected.to have_body_text(in_product_marketing_cta_text(track, series))
end
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment