FIX: error when group_in_subject enabled but no group in pm

This commit is contained in:
Leo McArdle 2018-03-11 12:22:11 +00:00
parent 3a35f459c7
commit 89f41f8236
2 changed files with 11 additions and 7 deletions

View File

@ -435,13 +435,11 @@ class UserNotifications < ActionMailer::Base
if post.topic.private_message?
subject_pm =
if opts[:show_group_in_subject]
if group = post.topic.allowed_groups&.first
if group.full_name
"[#{group.full_name}] "
else
"[#{group.name}] "
end
if opts[:show_group_in_subject] and group = post.topic.allowed_groups&.first
if group.full_name
"[#{group.full_name}] "
else
"[#{group.name}] "
end
else
I18n.t('subject_pm')

View File

@ -467,6 +467,12 @@ describe UserNotifications do
include_examples "includes first group name"
end
context "no groups in pm" do
it "includes %{optional_pm} in subject" do
expect(mail.subject).to include("[PM] ")
end
end
end
end