mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-08-13 18:40:43 +09:00
b065b40a34
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`.
20 lines
690 B
Ruby
20 lines
690 B
Ruby
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
|