Remove calls to trigger round robin notifications (#20506)

* remove calls to trigger round robin notifications

* remove tests
This commit is contained in:
Philip How 2024-01-10 13:44:57 +00:00 committed by GitHub
parent 2aa369c83d
commit 7d47ffef78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 0 additions and 41 deletions

View file

@ -65,7 +65,6 @@ class Comment < ApplicationRecord
after_create_commit :record_field_test_event
after_create_commit :send_email_notification, if: :should_send_email_notification?
after_create_commit :send_to_moderator
after_commit :calculate_score, on: %i[create update]

View file

@ -14,10 +14,6 @@ module Articles
# create mentions and notifications
# Send notifications to any mentioned users, followed by any users who follow the article's author.
Notification.send_to_mentioned_users_and_followers(article)
# using nth_published because it doesn't count draft articles by the new author
from_newish_author = article.nth_published_by_author < 3
Notification.send_moderation_notification(article) if from_newish_author
end
end
end

View file

@ -14,12 +14,6 @@ RSpec.describe Notifications::Moderation::Send, type: :service do
u = create(:user, :trusted, last_reacted_at: 2.days.ago, last_moderation_notification: last_moderation_time)
u.notification_setting.update(mod_roundrobin_notifications: true)
allow(User).to receive(:staff_account).and_return(staff_account)
# Creating a comment calls moderation job which itself call moderation service
Comment.skip_callback(:commit, :after, :send_to_moderator)
end
after do
Comment.set_callback(:commit, :after, :send_to_moderator)
end
it "calls comment_data since parameter is a comment" do

View file

@ -39,36 +39,6 @@ RSpec.describe Articles::PublishWorker, type: :worker do
expect(Notification).not_to have_received(:send_to_mentioned_users_and_followers).with(scheduled_article)
end
it "sends moderation notification for a published article" do
allow(Notification).to receive(:send_moderation_notification)
worker.perform
expect(Notification).to have_received(:send_moderation_notification).with(article)
end
it "does not send moderation notification for an unpublished article" do
unpublished = create(:unpublished_article, user: article.user)
allow(Notification).to receive(:send_moderation_notification)
worker.perform
expect(Notification).not_to have_received(:send_moderation_notification).with(unpublished)
end
it "does not send moderation notification for a scheduled article" do
scheduled = create(:article, published: true, published_at: Date.tomorrow)
allow(Notification).to receive(:send_moderation_notification)
worker.perform
expect(Notification).not_to have_received(:send_moderation_notification).with(scheduled)
end
it "does not send moderation notification for second published article" do
second = create(:published_article, title: "This is number two", user: article.user)
third = create(:published_article, title: "This is number three", user: article.user)
allow(Notification).to receive(:send_moderation_notification)
worker.perform
expect(Notification).to have_received(:send_moderation_notification).with(article)
expect(Notification).to have_received(:send_moderation_notification).with(second)
expect(Notification).not_to have_received(:send_moderation_notification).with(third)
end
context "with 2 articles" do
let!(:article2) { create(:article, published: true) }