Don't email about posts if the user deleted it.

This commit is contained in:
Robin Ward 2013-03-25 13:39:57 -04:00
parent ba315c6610
commit 90443dac30
2 changed files with 9 additions and 0 deletions

View File

@ -27,6 +27,9 @@ module Jobs
post = Post.where(id: args[:post_id]).first
return unless post.present?
# Don't email posts that were deleted
return if post.user_deleted?
# Don't send the email if the user has read the post
return if PostTiming.where(topic_id: post.topic_id, post_number: post.post_number, user_id: user.id).present?

View File

@ -70,6 +70,12 @@ describe Jobs::UserEmail do
Jobs::UserEmail.new.execute(type: :private_message, user_id: user.id, post_id: post.id)
end
it "doesn't send the email if the user deleted the post" do
EmailSender.any_instance.expects(:send).never
post.update_column(:user_deleted, true)
Jobs::UserEmail.new.execute(type: :private_message, user_id: user.id, post_id: post.id)
end
end