From 4a9e5d2fc9b97efff2ba8a1b7cb2a74e41de9bff Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 13 Feb 2020 08:59:03 -0800 Subject: [PATCH] Remove Reactions::UpdateReactableJob & spec (#6059) [deploy] --- app/jobs/reactions/update_reactable_job.rb | 13 --------- .../reactions/update_reactable_job_spec.rb | 29 ------------------- 2 files changed, 42 deletions(-) delete mode 100644 app/jobs/reactions/update_reactable_job.rb delete mode 100644 spec/jobs/reactions/update_reactable_job_spec.rb diff --git a/app/jobs/reactions/update_reactable_job.rb b/app/jobs/reactions/update_reactable_job.rb deleted file mode 100644 index b75793aa5..000000000 --- a/app/jobs/reactions/update_reactable_job.rb +++ /dev/null @@ -1,13 +0,0 @@ -module Reactions - class UpdateReactableJob < ApplicationJob - queue_as :update_reactable - - def perform(reaction_id) - reaction = Reaction.find_by(id: reaction_id) - return unless reaction&.reactable - - reaction.reactable.touch_by_reaction if reaction.reactable.respond_to?(:touch_by_reaction) - reaction.reactable.sync_reactions_count if rand(6) == 1 && reaction.reactable.respond_to?(:sync_reactions_count) - end - end -end diff --git a/spec/jobs/reactions/update_reactable_job_spec.rb b/spec/jobs/reactions/update_reactable_job_spec.rb deleted file mode 100644 index c18476ed0..000000000 --- a/spec/jobs/reactions/update_reactable_job_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -require "rails_helper" - -RSpec.describe Reactions::UpdateReactableJob, type: :job do - include_examples "#enqueues_job", "update_reactable", 2 - - describe "#perform_now" do - let(:article) { create(:article) } - let(:reaction) { create(:reaction, reactable: article) } - let(:comment) { create(:comment, commentable: article) } - let(:comment_reaction) { create(:reaction, reactable: comment) } - - it "updates the reactable Article" do - sidekiq_assert_enqueued_with(job: Articles::ScoreCalcWorker, args: [article.id]) do - described_class.perform_now(reaction.id) - end - end - - it "updates the reactable Comment" do - updated_at = 1.day.ago - comment.update_columns(updated_at: updated_at) - described_class.perform_now(comment_reaction.id) - expect(comment.reload.updated_at).to be > updated_at - end - - it "doesn't fail if a reaction doesn't exist" do - described_class.perform_now(Reaction.maximum(:id).to_i + 1) - end - end -end