mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-08-15 03:20:43 +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:
@@ -15,4 +15,20 @@ class AccountTest < ActiveSupport::TestCase
|
||||
accounts(:signal).update!(settings: { "restrict_room_creation_to_administrators" => "false" })
|
||||
assert_not accounts(:signal).reload.settings.restrict_room_creation_to_administrators?
|
||||
end
|
||||
|
||||
test "logo_variant is a resized variant of a variable logo" do
|
||||
accounts(:signal).logo.attach io: file_fixture("moon.jpg").open, filename: "moon.jpg", content_type: "image/jpeg"
|
||||
|
||||
assert_kind_of ActiveStorage::VariantWithRecord, accounts(:signal).logo_variant(:large)
|
||||
end
|
||||
|
||||
test "logo_variant is nil when the logo cannot be resized" do
|
||||
accounts(:signal).logo.attach io: file_fixture("pixel.bmp").open, filename: "pixel.bmp", content_type: "image/bmp"
|
||||
|
||||
assert_nil accounts(:signal).logo_variant(:large)
|
||||
end
|
||||
|
||||
test "logo_variant is nil without a logo" do
|
||||
assert_nil accounts(:signal).logo_variant(:large)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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