Remove cache headers from sidebars controller (#20002)

* Remove cache headers from sidebars controller

* Remove cache bust logic for sidebar
This commit is contained in:
Ben Halpern 2023-08-29 13:42:10 -04:00 committed by GitHub
parent 358a9a4b8f
commit 02db638d9d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 0 additions and 42 deletions

View file

@ -2,8 +2,6 @@ module Admin
class BillboardsController < Admin::ApplicationController
layout "admin"
after_action :bust_ad_caches, only: %i[create update destroy]
def index
@billboards = Billboard.order(id: :desc)
.page(params[:page]).per(50)
@ -67,9 +65,5 @@ module Admin
def authorize_admin
authorize Billboard, :access?, policy_class: InternalPolicy
end
def bust_ad_caches
EdgeCache::BustSidebar.call
end
end
end

View file

@ -1,10 +1,8 @@
class SidebarsController < ApplicationController
layout false
before_action :set_cache_control_headers, only: %i[show]
def show
get_latest_campaign_articles
set_surrogate_key_header "home-sidebar"
end
private

View file

@ -1,8 +0,0 @@
module EdgeCache
class BustSidebar
def self.call
cache_bust = EdgeCache::Bust.new
cache_bust.call("/sidebars/home")
end
end
end

View file

@ -53,12 +53,6 @@ RSpec.describe "/admin/customization/billboards" do
end.to change { Billboard.all.count }.by(1)
end
it "busts sidebar" do
allow(EdgeCache::BustSidebar).to receive(:call)
post_resource
expect(EdgeCache::BustSidebar).to have_received(:call).once
end
it "sets creator to current_user" do
post_resource
expect(Billboard.last.creator_id).to eq(super_admin.id)

View file

@ -2,11 +2,6 @@ require "rails_helper"
RSpec.describe "Sidebars" do
describe "GET /sidebars/home" do
it "includes surrogate headers" do
get "/sidebars/home"
expect(response.headers["Surrogate-Key"]).to eq("home-sidebar")
end
it "includes relevant parts" do
listing = create(:listing, published: true)
allow(Settings::General).to receive(:sidebar_tags).and_return(["rubymagoo"])

View file

@ -1,15 +0,0 @@
require "rails_helper"
RSpec.describe EdgeCache::BustSidebar, type: :service do
let(:cache_bust) { instance_double(EdgeCache::Bust) }
before do
allow(EdgeCache::Bust).to receive(:new).and_return(cache_bust)
allow(cache_bust).to receive(:call).with("/sidebars/home").once
end
it "busts the cache" do
described_class.call
expect(cache_bust).to have_received(:call).with("/sidebars/home").once
end
end