Remove Notifications::NotifiableActionJob (#5730) [deploy]

This commit is contained in:
serena 2020-01-27 13:54:40 +00:00 committed by Molly Struve
parent 7ad7320add
commit f2d96bacf2
2 changed files with 0 additions and 43 deletions

View file

@ -1,13 +0,0 @@
module Notifications
class NotifiableActionJob < ApplicationJob
queue_as :send_notifiable_action_notification
def perform(notifiable_id, notifiable_type, action, service = Notifications::NotifiableAction::Send)
# checking type, but leaving space for notifyable types
return unless notifiable_type == "Article"
notifiable = notifiable_type.constantize.find_by(id: notifiable_id)
service.call(notifiable, action) if notifiable
end
end
end

View file

@ -1,30 +0,0 @@
require "rails_helper"
RSpec.describe Notifications::NotifiableActionJob, type: :job do
include_examples "#enqueues_job", "send_notifiable_action_notification", 5
describe "#perform_now" do
let(:service) { double }
before do
allow(service).to receive(:call)
end
it "calls the service when existing notifiable passed" do
notifiable = create(:article)
described_class.perform_now(notifiable.id, "Article", "Published", service)
expect(service).to have_received(:call).with(notifiable, "Published").once
end
it "doesn't call a service when notifiable doesn't exist" do
described_class.perform_now(Article.maximum(:id).to_i + 1, "Article", "Published", service)
expect(service).not_to have_received(:call)
end
it "doesn't call a service when unexpected notifiable type passed" do
user = create(:user)
described_class.perform_now(user.id, "User", "Upgraded", service)
expect(service).not_to have_received(:call)
end
end
end