Immediate avatar and embed variants

Process variants synchronously on attachment to close the window between
image upload and variant availability, guaranteeing that we won't have
lazy variant processing attempts in GET requests.

Tradeoff is that we do variant processing in upload requests, which is
actually desirable. We're working with images that should take
milliseconds to resize given that we'll already have the file on hand.

References https://github.com/rails/rails/pull/51951
This commit is contained in:
Jeremy Daer
2025-12-04 23:17:21 -08:00
parent d729cf59f9
commit 21f3f72647
9 changed files with 59 additions and 17 deletions
@@ -22,11 +22,12 @@ class Notification::BundleMailerTest < ActionMailer::TestCase
end
test "renders avatar with external image URL when avatar is attached" do
@user.avatar.attach(
blob = ActiveStorage::Blob.create_and_upload!(
io: File.open(Rails.root.join("test", "fixtures", "files", "avatar.png")),
filename: "avatar.png",
content_type: "image/png"
)
@user.avatar.attach(blob)
create_notification(@user)