Don't email about posts if the user deleted it.
This commit is contained in:
parent
ba315c6610
commit
90443dac30
@ -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?
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user