We don't need to raise an error when no post is present. Just noop.

This commit is contained in:
Robin Ward 2017-05-08 15:08:29 -04:00
parent 7a0501c0c0
commit 4f6e5fed2a
2 changed files with 3 additions and 5 deletions

View File

@ -10,8 +10,7 @@ module Jobs
post_id = args[:post_id]
post = post_id ? Post.with_deleted.find_by(id: post_id) : nil
raise Discourse::InvalidParameters.new(:post_id) unless post
return if post.trashed? || post.user_deleted? || !post.topic
return if !post || post.trashed? || post.user_deleted? || !post.topic
users =
User.activated.not_blocked.not_suspended.real

View File

@ -32,9 +32,8 @@ describe Jobs::NotifyMailingListSubscribers do
before { SiteSetting.disable_mailing_list_mode = false }
context "with an invalid post_id" do
it "throws an error" do
expect { Jobs::NotifyMailingListSubscribers.new.execute(post_id: -1) }.to raise_error(Discourse::InvalidParameters)
end
before { post.update(deleted_at: Time.now) }
include_examples "no emails"
end
context "with a deleted post" do