Turn off attachment previews on large files

ref: https://fizzy.37signals.com/5986089/collections/7/cards/1302
This commit is contained in:
Mike Dalessio
2025-08-19 12:16:24 -04:00
parent defb11e8c0
commit a711975904
2 changed files with 31 additions and 0 deletions
@@ -0,0 +1,13 @@
require "test_helper"
class ActiveStorageBlobPreviewableTest < ActiveSupport::TestCase
test "small files are previewable" do
blob = ActiveStorage::Blob.new(filename: "test.mp4", content_type: "video/mp4", byte_size: 1024 * 1024, key: "test", checksum: "abc")
assert blob.previewable?
end
test "large files are not previewable" do
blob = ActiveStorage::Blob.new(filename: "test.mp4", content_type: "video/mp4", byte_size: ActiveStorageBlobPreviewable::MAX_PREVIEWABLE_SIZE + 1, key: "test", checksum: "abc")
assert_not blob.previewable?
end
end