Skip to content

Commit 03c9781

Browse files
nbudinclaude
andcommitted
Add test exercising image_processing variant generation
Guards against regressions from image_processing version upgrades (e.g. 2.x drops mini_magick and changes the vips pipeline API). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 2a69f95 commit 03c9781

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# frozen_string_literal: true
2+
3+
require "test_helper"
4+
5+
class ActiveStorageAttachmentTest < ActiveSupport::TestCase
6+
let(:convention) { create(:convention) }
7+
let(:event) { create(:event, convention:) }
8+
9+
it "can generate a resized variant of an attached image" do
10+
event.images.attach(
11+
io: Rails.root.join("test/files/war_bond.png").open,
12+
filename: "war_bond.png",
13+
content_type: "image/png"
14+
)
15+
16+
attachment = event.images.first
17+
assert attachment.representable?, "Expected PNG attachment to be representable"
18+
19+
# Exercises image_processing - calls into the vips pipeline via resize_to_limit.
20+
# This is the same operation used by ActiveStorageAttachmentType#resized_url.
21+
variant = attachment.representation(resize_to_limit: [100, 100]).processed
22+
assert variant.present?
23+
end
24+
end

0 commit comments

Comments
 (0)