Merge pull request #2422 from peternlewis/honor_email_always_even_if_read
Honor email_always even if notification has been read
This commit is contained in:
commit
7a2d64b27f
2 changed files with 8 additions and 1 deletions
|
@ -46,7 +46,7 @@ module Jobs
|
||||||
email_args[:post] ||= notification.post
|
email_args[:post] ||= notification.post
|
||||||
email_args[:notification] = notification
|
email_args[:notification] = notification
|
||||||
|
|
||||||
return skip(I18n.t('email_log.notification_already_read')) if notification.read?
|
return skip(I18n.t('email_log.notification_already_read')) if notification.read? && !@user.email_always
|
||||||
end
|
end
|
||||||
|
|
||||||
skip_reason = skip_email_for_post(email_args[:post], @user)
|
skip_reason = skip_email_for_post(email_args[:post], @user)
|
||||||
|
|
|
@ -124,6 +124,13 @@ describe Jobs::UserEmail do
|
||||||
Jobs::UserEmail.new.execute(type: :user_mentioned, user_id: user.id, notification_id: notification.id)
|
Jobs::UserEmail.new.execute(type: :user_mentioned, user_id: user.id, notification_id: notification.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "does send the email if the notification has been seen but the user is set for email_always" do
|
||||||
|
Email::Sender.any_instance.expects(:send)
|
||||||
|
notification.update_column(:read, true)
|
||||||
|
user.update_column(:email_always, true)
|
||||||
|
Jobs::UserEmail.new.execute(type: :user_mentioned, user_id: user.id, notification_id: notification.id)
|
||||||
|
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
|
||||||
Email::Sender.any_instance.expects(:send).never
|
Email::Sender.any_instance.expects(:send).never
|
||||||
post.update_column(:user_deleted, true)
|
post.update_column(:user_deleted, true)
|
||||||
|
|
Reference in a new issue