docbrown/spec/services/edge_cache/bust_user_spec.rb
Daniel Uber 3e432c9047
When busting user cache, also clear the api response (#13465)
* When busting user cache, also clear the api response

This should fix #13293 by clearing both the UI copy and the api copy of the
user's page.

* Update spec to include the api path
2021-04-22 09:16:15 -05:00

38 lines
842 B
Ruby

require "rails_helper"
RSpec.describe EdgeCache::BustUser, type: :service do
let(:cache_bust) { instance_double(EdgeCache::Bust) }
let(:user) { create(:user) }
let(:paths) do
username = user.username
[
"/#{username}",
"/#{username}?i=i",
"/#{username}/comments",
"/#{username}/comments?i=i",
"/#{username}/comments/?i=i",
"/live/#{username}",
"/live/#{username}?i=i",
"/feed/#{username}",
"/api/users/#{user.id}",
]
end
before do
allow(EdgeCache::Bust).to receive(:new).and_return(cache_bust)
paths.each do |path|
allow(cache_bust).to receive(:call).with(path).once
end
end
it "busts the cache" do
described_class.call(user)
paths.each do |path|
expect(cache_bust).to have_received(:call).with(path).once
end
end
end