Remove Reactions::UpdateReactableJob & spec (#6059) [deploy]

This commit is contained in:
Alex 2020-02-13 08:59:03 -08:00 committed by GitHub
parent 611706f3f2
commit 4a9e5d2fc9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 42 deletions

View file

@ -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

View file

@ -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