Skip to content

A platform for community discussion. Free, open, simple.

FIX: Notify mailing list subscribers on category change (#28811)

Yuvaraj J65a1e149adce
diff --git a/app/jobs/regular/notify_category_change.rb b/app/jobs/regular/notify_category_change.rb
index f1f6c020f04..ae721eecea8 100644
--- a/app/jobs/regular/notify_category_change.rb
+++ b/app/jobs/regular/notify_category_change.rb
@@ -13,6 +13,7 @@ module Jobs
include_tag_watchers: false,
)
post_alerter.notify_first_post_watchers(post, post_alerter.category_watchers(post.topic))
+ ::Jobs.enqueue(:notify_mailing_list_subscribers, post_id: post.id)
end
end
end
diff --git a/spec/jobs/notify_category_change_spec.rb b/spec/jobs/notify_category_change_spec.rb
index 8348fc21644..a5e196b1fad 100644
--- a/spec/jobs/notify_category_change_spec.rb
+++ b/spec/jobs/notify_category_change_spec.rb
@@ -19,4 +19,18 @@ RSpec.describe ::Jobs::NotifyCategoryChange do
Notification.count
}
end
+
+ context "when mailing list mode is enabled" do
+ before { SiteSetting.disable_mailing_list_mode = false }
+ before { regular_user.user_option.update(mailing_list_mode: true, mailing_list_mode_frequency: 1) }
+ before { Jobs.run_immediately! }
+
+ it "notifies mailing list subscribers" do
+ post.topic.update!(category: category)
+
+ expected_args = { "post_id" => post.id, "current_site_id" => "default" }
+ Jobs::NotifyMailingListSubscribers.any_instance.expects(:execute).with(expected_args).once
+ described_class.new.execute(post_id: post.id, notified_user_ids: [])
+ end
+ end
end