From 4f6e5fed2a450f41c8d8ad3e2b7553ebb9e7ad40 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Mon, 8 May 2017 15:08:29 -0400 Subject: [PATCH] We don't need to raise an error when no post is present. Just noop. --- app/jobs/regular/notify_mailing_list_subscribers.rb | 3 +-- spec/jobs/notify_mailing_list_subscribers_spec.rb | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/jobs/regular/notify_mailing_list_subscribers.rb b/app/jobs/regular/notify_mailing_list_subscribers.rb index 017cc248bf..393b324dc1 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 dc732b86a8..1749b1df15 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