diff --git a/app/jobs/reactions/bust_homepage_cache_job.rb b/app/jobs/reactions/bust_homepage_cache_job.rb deleted file mode 100644 index 5492ab370..000000000 --- a/app/jobs/reactions/bust_homepage_cache_job.rb +++ /dev/null @@ -1,19 +0,0 @@ -module Reactions - class BustHomepageCacheJob < ApplicationJob - queue_as :bust_homepage_cache_from_reactions - - def perform(reaction_id, cache_buster = CacheBuster) - reaction = Reaction.find_by(id: reaction_id, reactable_type: "Article") - return unless reaction&.reactable - - featured_articles_ids = Article.where(featured: true).order("hotness_score DESC").limit(3).pluck(:id) - return unless featured_articles_ids.include?(reaction.reactable_id) - - reaction.reactable.touch - cache_buster.bust("/") - cache_buster.bust("/") - cache_buster.bust("/?i=i") - cache_buster.bust("?i=i") - end - end -end diff --git a/spec/jobs/reactions/bust_homepage_cache_job_spec.rb b/spec/jobs/reactions/bust_homepage_cache_job_spec.rb deleted file mode 100644 index 51ac06d6d..000000000 --- a/spec/jobs/reactions/bust_homepage_cache_job_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -require "rails_helper" - -RSpec.describe Reactions::BustHomepageCacheJob, type: :job do - include_examples "#enqueues_job", "bust_homepage_cache_from_reactions", 2 - - describe "#perform_now" do - let(:user) { create(:user) } - let(:article) { create(:article, featured: true) } - let(:reaction) { create(:reaction, reactable: article, user: user) } - let(:comment) { create(:comment, commentable: article) } - let(:comment_reaction) { create(:reaction, reactable: comment, user: user) } - let(:buster) { double } - - before do - allow(buster).to receive(:bust) - end - - it "busts the homepage cache when reactable is an Article" do - described_class.perform_now(reaction.id, buster) - expect(buster).to have_received(:bust).exactly(4) - end - - it "doesn't bust the homepage cache when reactable is a Comment" do - described_class.perform_now(comment_reaction.id, buster) - expect(buster).not_to have_received(:bust) - 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