Remove Notifications::ModerationNotificationJob (#5905) [deploy]
This commit is contained in:
parent
8578c78158
commit
8261ab74d7
2 changed files with 0 additions and 78 deletions
|
|
@ -1,18 +0,0 @@
|
|||
module Notifications
|
||||
class ModerationNotificationJob < ApplicationJob
|
||||
queue_as :send_moderation_notification
|
||||
|
||||
def perform(notifiable_id, service = Notifications::Moderation::Send)
|
||||
random_moderators = Notifications::Moderation.available_moderators.order(Arel.sql("RANDOM()")).first(2)
|
||||
return unless random_moderators.any?
|
||||
|
||||
# notifiable is currently only comment
|
||||
notifiable = Comment.find_by(id: notifiable_id)
|
||||
return unless notifiable
|
||||
|
||||
random_moderators.each do |mod|
|
||||
service.call(mod, notifiable)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Notifications::ModerationNotificationJob do
|
||||
include_examples "#enqueues_job", "send_moderation_notification", 458
|
||||
|
||||
describe "#perform_now" do
|
||||
let(:id) { rand(1000) }
|
||||
let(:moderation_notification_service) { double }
|
||||
let(:comment) do
|
||||
comment = double
|
||||
allow(Comment).to receive(:find_by).and_return(comment)
|
||||
end
|
||||
let(:mod) do
|
||||
last_moderation_time = Time.zone.now - Notifications::Moderation::MODERATORS_AVAILABILITY_DELAY - 2.hours
|
||||
create(:user, :trusted, last_moderation_notification: last_moderation_time)
|
||||
end
|
||||
|
||||
before do
|
||||
allow(moderation_notification_service).to receive(:call)
|
||||
end
|
||||
|
||||
describe "When available moderator(s) + comment" do
|
||||
it "calls the service" do
|
||||
mod
|
||||
comment
|
||||
check_received_call
|
||||
end
|
||||
end
|
||||
|
||||
describe "When no available moderator" do
|
||||
it "does not call the service" do
|
||||
comment
|
||||
check_non_received_call
|
||||
end
|
||||
end
|
||||
|
||||
describe "When no valid comment" do
|
||||
it "does not call the service" do
|
||||
mod
|
||||
check_non_received_call
|
||||
end
|
||||
end
|
||||
|
||||
describe "When no valid comment + no moderator" do
|
||||
it "does not call the service" do
|
||||
check_non_received_call
|
||||
end
|
||||
end
|
||||
|
||||
def check_received_call
|
||||
described_class.perform_now(id, moderation_notification_service)
|
||||
expect(moderation_notification_service).to have_received(:call)
|
||||
end
|
||||
|
||||
def check_non_received_call
|
||||
described_class.perform_now(id, moderation_notification_service)
|
||||
expect(moderation_notification_service).not_to have_received(:call)
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Reference in a new issue