mirror of
https://github.com/mastodon/mastodon.git
synced 2024-08-20 21:08:15 -07:00
Don't push to cache buster if attachment path is nil
This commit is contained in:
parent
0d85a79f19
commit
d41848932c
2 changed files with 8 additions and 5 deletions
|
@ -422,7 +422,7 @@ class MediaAttachment < ApplicationRecord
|
||||||
attachment = public_send(attachment_name)
|
attachment = public_send(attachment_name)
|
||||||
styles = DEFAULT_STYLES | attachment.styles.keys
|
styles = DEFAULT_STYLES | attachment.styles.keys
|
||||||
styles.map { |style| attachment.path(style) }
|
styles.map { |style| attachment.path(style) }
|
||||||
end
|
end.compact
|
||||||
rescue => e
|
rescue => e
|
||||||
# We really don't want any error here preventing media deletion
|
# We really don't want any error here preventing media deletion
|
||||||
Rails.logger.warn "Error #{e.class} busting cache: #{e.message}"
|
Rails.logger.warn "Error #{e.class} busting cache: #{e.message}"
|
||||||
|
|
|
@ -303,11 +303,14 @@ RSpec.describe MediaAttachment, :attachment_processing do
|
||||||
original_path = media.file.path(:original)
|
original_path = media.file.path(:original)
|
||||||
small_path = media.file.path(:small)
|
small_path = media.file.path(:small)
|
||||||
thumbnail_path = media.thumbnail.path(:original)
|
thumbnail_path = media.thumbnail.path(:original)
|
||||||
|
paths = [original_path, small_path, thumbnail_path]
|
||||||
|
|
||||||
expect { media.destroy }
|
media.destroy
|
||||||
.to enqueue_sidekiq_job(CacheBusterWorker).with(original_path)
|
|
||||||
.and enqueue_sidekiq_job(CacheBusterWorker).with(small_path)
|
paths.each do |path|
|
||||||
.and enqueue_sidekiq_job(CacheBusterWorker).with(thumbnail_path)
|
expect(CacheBusterWorker).to have_enqueued_sidekiq_job(path) if path
|
||||||
|
expect(CacheBusterWorker).to_not have_enqueued_sidekiq_job(path) if path.nil?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue