docbrown/spec/services/edge_cache/bust_organization_spec.rb
Alex 494359fd21
Create services for busting organizations, podcast episodes, listings, and users (#11832)
* Create service for bust_organization

* Create bust_podcast_episode_service

* Add error spec to BustOrganization

* Create bust_listings

* Create bust_user service
2020-12-11 08:59:24 -05:00

26 lines
831 B
Ruby

require "rails_helper"
RSpec.describe EdgeCache::BustOrganization, type: :service do
let(:organization) { create(:organization) }
let(:article) { create(:article, organization: organization) }
let(:slug) { "slug" }
before do
allow(described_class).to receive(:bust).with("/#{slug}").once
allow(described_class).to receive(:bust).with(article.path).once
end
it "busts the cache" do
described_class.call(organization, slug)
expect(described_class).to have_received(:bust).with("/#{slug}").once
expect(described_class).to have_received(:bust).with(article.path).once
end
it "logs an error" do
allow(described_class).to receive(:bust).with("/5").once
allow(Rails.logger).to receive(:error)
described_class.call(4, 5)
expect(Rails.logger).to have_received(:error).once
end
end