mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-08-19 05:13:46 +09:00
Disable libvips unfuzzed operations (#226)
and add test coverage for (un)supported file types. The avatar and logo variants move into the models and return nil for content types that are no longer variable, so the controllers fall back to the initials avatar and stock logo icon instead of raising `ActiveStorage::InvariableError`.
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
require "test_helper"
|
||||
|
||||
class User::AvatarTest < ActiveSupport::TestCase
|
||||
test "avatar_variant is a resized variant of a variable avatar" do
|
||||
users(:kevin).avatar.attach io: file_fixture("moon.jpg").open, filename: "moon.jpg", content_type: "image/jpeg"
|
||||
|
||||
assert_kind_of ActiveStorage::VariantWithRecord, users(:kevin).avatar_variant
|
||||
end
|
||||
|
||||
test "avatar_variant is nil when the avatar cannot be resized" do
|
||||
users(:kevin).avatar.attach io: file_fixture("pixel.bmp").open, filename: "pixel.bmp", content_type: "image/bmp"
|
||||
|
||||
assert_nil users(:kevin).avatar_variant
|
||||
end
|
||||
|
||||
test "avatar_variant is nil without an avatar" do
|
||||
assert_nil users(:kevin).avatar_variant
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user