0
0
Fork 0

Bust CDN cache on media deletion (#31353)

This commit is contained in:
Claire 2024-08-09 14:48:34 +02:00 committed by GitHub
parent 9bae237792
commit 994ef16b72
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 47 additions and 0 deletions

View file

@ -292,6 +292,25 @@ RSpec.describe MediaAttachment, :attachment_processing do
end
end
describe 'cache deletion hooks' do
let(:media) { Fabricate(:media_attachment) }
before do
allow(Rails.configuration.x).to receive(:cache_buster_enabled).and_return(true)
end
it 'queues CacheBusterWorker jobs' do
original_path = media.file.path(:original)
small_path = media.file.path(:small)
thumbnail_path = media.thumbnail.path(:original)
expect { media.destroy }
.to enqueue_sidekiq_job(CacheBusterWorker).with(original_path)
.and enqueue_sidekiq_job(CacheBusterWorker).with(small_path)
.and enqueue_sidekiq_job(CacheBusterWorker).with(thumbnail_path)
end
end
private
def media_metadata