docbrown/spec/services/edge_cache/bust_article_spec.rb
Alex d0eb582236
Add bust_article service (#11788)
* Add bust_article service

* Make timestamps lambdas

* Remove nil safe operators

* Updated bust_article specs

* Add spec for TIMEFRAMES and relative time
2020-12-08 11:56:43 -05:00

31 lines
1.1 KiB
Ruby

require "rails_helper"
RSpec.describe EdgeCache::BustArticle, type: :service do
let(:article) { create(:article) }
before do
allow(article).to receive(:purge)
allow(described_class).to receive(:bust)
allow(described_class).to receive(:bust_home_pages)
allow(described_class).to receive(:bust_tag_pages)
end
it "busts the cache" do
described_class.call(article)
expect(article).to have_received(:purge).once
expect(described_class).to have_received(:bust).exactly(9).times
expect(described_class).to have_received(:bust).with(article.path).once
expect(described_class).to have_received(:bust_home_pages).with(article).once
expect(described_class).to have_received(:bust_tag_pages).with(article).once
end
context "when an article is part of an organization" do
it "busts the organization slug" do
organization = create(:organization)
article.organization = organization
described_class.call(article)
expect(described_class).to have_received(:bust).with("/#{article.organization.slug}").once
end
end
end