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:
Sam 2014-06-20 16:14:37 +10:00
commit 7a2d64b27f
2 changed files with 8 additions and 1 deletions

View File

@ -46,7 +46,7 @@ module Jobs
email_args[:post] ||= notification.post
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
skip_reason = skip_email_for_post(email_args[:post], @user)

View File

@ -124,6 +124,13 @@ describe Jobs::UserEmail do
Jobs::UserEmail.new.execute(type: :user_mentioned, user_id: user.id, notification_id: notification.id)
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
Email::Sender.any_instance.expects(:send).never
post.update_column(:user_deleted, true)