diff --git a/app/jobs/regular/notify_mailing_list_subscribers.rb b/app/jobs/regular/notify_mailing_list_subscribers.rb index 017cc248bf4..393b324dc12 100644 --- a/app/jobs/regular/notify_mailing_list_subscribers.rb +++ b/app/jobs/regular/notify_mailing_list_subscribers.rb @@ -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 diff --git a/spec/jobs/notify_mailing_list_subscribers_spec.rb b/spec/jobs/notify_mailing_list_subscribers_spec.rb index dc732b86a8c..1749b1df15a 100644 --- a/spec/jobs/notify_mailing_list_subscribers_spec.rb +++ b/spec/jobs/notify_mailing_list_subscribers_spec.rb @@ -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