docbrown/spec/workers/articles/bust_cache_worker_spec.rb
Alex d03d03bc39
Update bust_article to BustArticle (#11931)
* Update bust_article to BustArticle

* Fix spec
2020-12-17 12:20:44 -05:00

39 lines
1,012 B
Ruby

require "rails_helper"
RSpec.describe Articles::BustCacheWorker, type: :worker do
include_examples "#enqueues_on_correct_queue", "high_priority", 1
describe "#perform" do
let(:worker) { subject }
context "with article" do
let(:article) { double }
let(:article_id) { 1 }
before do
allow(Article).to receive(:find_by).with(id: article_id).and_return(article)
allow(EdgeCache::BustArticle).to receive(:call).with(article)
end
it "busts the cache" do
worker.perform(article_id)
expect(EdgeCache::BustArticle).to have_received(:call).with(article)
end
end
context "without article" do
before do
allow(EdgeCache::BustArticle).to receive(:call)
end
it "does not error" do
expect { worker.perform(nil) }.not_to raise_error
end
it "does not bust cache" do
worker.perform(nil)
expect(EdgeCache::BustArticle).not_to have_received(:call)
end
end
end
end