Bust sidebar when display ad is updated (#12025)

* Bust sidebar when display ad is updated

* Fix test
This commit is contained in:
Ben Halpern 2020-12-25 12:02:19 -05:00 committed by GitHub
parent eefec99472
commit 839a30c70e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View file

@ -2,6 +2,8 @@ module Admin
class DisplayAdsController < Admin::ApplicationController
layout "admin"
after_action :bust_ad_caches, only: %i[create update destroy]
def index
@display_ads = DisplayAd.order(id: :desc)
.joins(:organization)
@ -66,5 +68,9 @@ module Admin
def authorize_admin
authorize DisplayAd, :access?, policy_class: InternalPolicy
end
def bust_ad_caches
EdgeCache::BustSidebar.call
end
end
end

View file

@ -50,6 +50,12 @@ RSpec.describe "/admin/display_ads", type: :request do
post_resource
end.to change { DisplayAd.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
end
describe "PUT /admin/display_ads" do