Skip to content

Commit

Permalink
BUG: Cast FileProxy sizes to integer (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-nerdgeschoss authored Jul 23, 2024
1 parent 2f41a1e commit e6217da
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/shimmer/utils/file_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def message_verifier

def initialize(blob_id:, width: nil, height: nil)
@blob_id = blob_id
@resize = [width, height] if width || height
@resize = [width&.to_i, height&.to_i] if width || height
end

def path
Expand Down
8 changes: 8 additions & 0 deletions spec/utils/shimmer/file_proxy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@
expect(dimensions(variant.processed.image.blob)).to eq({width: 290, height: 100})
end

it "works if passing width or height as string" do
proxy = Shimmer::FileProxy.new(blob_id: blob.id, width: "290", height: "100")
id = proxy.send(:id)
variant = Shimmer::FileProxy.restore(id).variant

expect(dimensions(variant.processed.image.blob)).to eq({width: 290, height: 100})
end

it "works if not resizing" do
proxy = Shimmer::FileProxy.new(blob_id: blob.id)
id = proxy.send(:id)
Expand Down

0 comments on commit e6217da

Please sign in to comment.