Remove New Reaction Job and Spec (#5422) [deploy]
This commit is contained in:
parent
5c9302f5f1
commit
d479a77aab
2 changed files with 0 additions and 50 deletions
|
|
@ -1,20 +0,0 @@
|
|||
module Notifications
|
||||
class NewReactionJob < ApplicationJob
|
||||
queue_as :send_new_reaction_notification
|
||||
|
||||
# @param reaction_data [Hash]
|
||||
# * :reactable_id [Integer] - article or comment id
|
||||
# * :reactable_type [String] - "Article" or "Comment"
|
||||
# * :reactable_user_id [Integer] - user id
|
||||
# @param receiver_data [Hash]
|
||||
# * :id [Integer] - user or organization id
|
||||
# * :klass [String] - "User" or "Organization"
|
||||
def perform(reaction_data, receiver_data, service = Notifications::Reactions::Send)
|
||||
receiver_klass = receiver_data.fetch(:klass)
|
||||
return unless %w[User Organization].include?(receiver_klass)
|
||||
|
||||
receiver = receiver_klass.constantize.find_by(id: receiver_data.fetch(:id))
|
||||
service.call(reaction_data, receiver) if receiver
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Notifications::NewReactionJob, type: :job do
|
||||
let(:reaction_data) { { reactable_type: "Comment", reactable_id: 1, reactable_user_id: 2 } }
|
||||
let(:org) { create(:organization) }
|
||||
let(:receiver_data) { { klass: "Organization", id: org.id } }
|
||||
|
||||
include_examples "#enqueues_job", "send_new_reaction_notification", [{}, {}, true]
|
||||
|
||||
describe "#perform_now" do
|
||||
let(:reaction_service) { double }
|
||||
|
||||
before { allow(reaction_service).to receive(:call) }
|
||||
|
||||
it "calls the service" do
|
||||
described_class.perform_now(reaction_data, receiver_data, reaction_service)
|
||||
expect(reaction_service).to have_received(:call).with(reaction_data, org).once
|
||||
end
|
||||
|
||||
it "doesn't call if is a receiver is of a wrong class" do
|
||||
described_class.perform_now(reaction_data, { klass: "Tag", id: 10 }, reaction_service)
|
||||
expect(reaction_service).not_to have_received(:call)
|
||||
end
|
||||
|
||||
it "doesn't call if is a receiver doesn't exist" do
|
||||
described_class.perform_now(reaction_data, { klass: "Organization", id: org.id + 1 }, reaction_service)
|
||||
expect(reaction_service).not_to have_received(:call)
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Reference in a new issue