Remove unused ModerationService (#2805) [ci skip]

This commit is contained in:
Anna Buianova 2019-05-13 23:16:06 +03:00 committed by Mac Siri
parent 01d0ff8c1d
commit 24bdfb1ef5
3 changed files with 0 additions and 41 deletions

View file

@ -458,11 +458,6 @@ class Article < ApplicationRecord
Notification.update_notifications(self, "Published")
end
# def send_to_moderator
# ModerationService.new.send_moderation_notification(self) if published
# turned off for now
# end
def before_destroy_actions
bust_cache
remove_algolia_index

View file

@ -1,19 +0,0 @@
class ModerationService
def initialize
@available_moderators = User.with_role(:trusted).where("last_moderation_notification < ?", 28.hours.ago)
end
def send_moderation_notification(object)
return unless @available_moderators.any?
moderator = @available_moderators.sample
Notification.create(
user_id: moderator.id,
notifiable_id: object.id,
notifiable_type: object.class.name,
action: "Moderation",
)
moderator.update_column(:last_moderation_notification, Time.current)
end
handle_asynchronously :send_moderation_notification
end

View file

@ -1,17 +0,0 @@
require "rails_helper"
RSpec.describe ModerationService do
let(:mod) { create(:user, :trusted) }
let(:article) { create(:user) }
describe "#send_moderation_notification" do
it "sends Notification to a moderator" do
mod
allow(Notification).to receive(:create)
run_background_jobs_immediately do
described_class.new.send_moderation_notification(article)
end
expect(Notification).to have_received(:create).exactly(:once)
end
end
end