From f2d96bacf20a84f0a8b968b9e618406f5d05dc62 Mon Sep 17 00:00:00 2001 From: serena Date: Mon, 27 Jan 2020 13:54:40 +0000 Subject: [PATCH] Remove Notifications::NotifiableActionJob (#5730) [deploy] --- .../notifications/notifiable_action_job.rb | 13 -------- .../notifiable_action_job_spec.rb | 30 ------------------- 2 files changed, 43 deletions(-) delete mode 100644 app/jobs/notifications/notifiable_action_job.rb delete mode 100644 spec/jobs/notifications/notifiable_action_job_spec.rb diff --git a/app/jobs/notifications/notifiable_action_job.rb b/app/jobs/notifications/notifiable_action_job.rb deleted file mode 100644 index 7afa3abfb..000000000 --- a/app/jobs/notifications/notifiable_action_job.rb +++ /dev/null @@ -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 diff --git a/spec/jobs/notifications/notifiable_action_job_spec.rb b/spec/jobs/notifications/notifiable_action_job_spec.rb deleted file mode 100644 index 95ae6eafd..000000000 --- a/spec/jobs/notifications/notifiable_action_job_spec.rb +++ /dev/null @@ -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