Make sure there is no empty <p> in the badge email (#7043)

This commit is contained in:
rhymes 2020-04-03 00:25:51 +02:00 committed by GitHub
parent b72fe0f03c
commit cf1f6cc209
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 3 deletions

View file

@ -9,7 +9,7 @@
<%= @badge.description %>
</p>
<% if @badge_achievement.rewarding_context_message %>
<% if @badge_achievement.rewarding_context_message.present? %>
<p>
<em>
<%= @badge_achievement.rewarding_context_message.html_safe %>

View file

@ -206,12 +206,19 @@ RSpec.describe NotifyMailer, type: :mailer do
expect(email.html_part.body).to include(CGI.escape(URL.url("/hey")))
end
it "does not include the rewarding_context_message in the email" do
it "does not include the nil rewarding_context_message in the email" do
allow(badge_achievement).to receive(:rewarding_context_message).and_return(nil)
expect(email.html_part.body).not_to include("Hello <a")
expect(email.html_part.body).not_to include(CGI.escape(URL.url("/hey")))
end
it "does not include the empty rewarding_context_message in the email" do
allow(badge_achievement).to receive(:rewarding_context_message).and_return("")
expect(email.html_part.body).not_to include("Hello <a")
expect(email.html_part.body).not_to include(CGI.escape(URL.url("/hey")))
end
end
context "when rendering the text email" do
@ -234,12 +241,19 @@ RSpec.describe NotifyMailer, type: :mailer do
expect(email.text_part.body).not_to include(URL.url("/hey"))
end
it "does not include the rewarding_context_message in the email" do
it "does not include the nil rewarding_context_message in the email" do
allow(badge_achievement).to receive(:rewarding_context_message).and_return(nil)
expect(email.text_part.body).not_to include("Hello Yoho")
expect(email.text_part.body).not_to include(URL.url("/hey"))
end
it "does not include the empty rewarding_context_message in the email" do
allow(badge_achievement).to receive(:rewarding_context_message).and_return("")
expect(email.text_part.body).not_to include("Hello Yoho")
expect(email.text_part.body).not_to include(URL.url("/hey"))
end
end
end