mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
FIX: Topic and Post may be nil
.
This commit is contained in:
parent
b500f35d14
commit
f89e9024ba
2 changed files with 8 additions and 2 deletions
|
@ -86,7 +86,7 @@ module Jobs
|
||||||
end
|
end
|
||||||
|
|
||||||
if user.user_option.mailing_list_mode? &&
|
if user.user_option.mailing_list_mode? &&
|
||||||
!post.topic.private_message? &&
|
(!post.try(:topic).try(:private_message?)) &&
|
||||||
NOTIFICATIONS_SENT_BY_MAILING_LIST.include?(email_args[:notification_type])
|
NOTIFICATIONS_SENT_BY_MAILING_LIST.include?(email_args[:notification_type])
|
||||||
# no need to log a reason when the mail was already sent via the mailing list job
|
# no need to log a reason when the mail was already sent via the mailing list job
|
||||||
return [nil, nil]
|
return [nil, nil]
|
||||||
|
|
|
@ -200,6 +200,12 @@ describe Jobs::UserEmail do
|
||||||
Jobs::UserEmail.new.execute(type: :user_mentioned, user_id: user.id, notification_id: notification.id, post_id: post.id)
|
Jobs::UserEmail.new.execute(type: :user_mentioned, user_id: user.id, notification_id: notification.id, post_id: post.id)
|
||||||
# other times, we only pass the type of notification
|
# other times, we only pass the type of notification
|
||||||
Jobs::UserEmail.new.execute(type: :user_mentioned, user_id: user.id, notification_type: "posted", post_id: post.id)
|
Jobs::UserEmail.new.execute(type: :user_mentioned, user_id: user.id, notification_type: "posted", post_id: post.id)
|
||||||
|
# When post is nil
|
||||||
|
Jobs::UserEmail.new.execute(type: :user_mentioned, user_id: user.id, notification_type: "posted")
|
||||||
|
# When post does not have a topic
|
||||||
|
post = Fabricate(:post)
|
||||||
|
post.topic.destroy
|
||||||
|
Jobs::UserEmail.new.execute(type: :user_mentioned, user_id: user.id, notification_type: "posted", post_id: post)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't send the email if the post has been user deleted" do
|
it "doesn't send the email if the post has been user deleted" do
|
||||||
|
|
Loading…
Reference in a new issue