Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions gems/activestorage/8.1/_test/test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
class User < ActiveRecord::Base
has_one_attached :one_image
has_many_attached :many_image
has_one_attached :avatar do |attachable|
attachable.variant :thumb, resize_to_limit: [100, 100]
end
has_many_attached :photos do |attachable|
attachable.named_variants
end
end

user = User.new
one = ActiveStorage::Attached::One.new("one_image", user)
one.url
ActiveStorage::Blob.new.signed_id(purpose: :download).size

blob = ActiveStorage::Blob.new
blob.content_type&.start_with?("image/")
blob.byte_size + 1
blob.checksum&.size
blob.metadata["width"]
blob.service_name.to_sym
blob.created_at.to_date
attachment = ActiveStorage::Attachment.new
attachment.name.to_sym
attachment.blob.byte_size
attachment.created_at.to_date

blob.key.size
blob.filename.extension.upcase
blob.filename.base.upcase
blob.filename.to_s.upcase
blob.url(expires_in: 5.minutes).size
blob.service_url_for_direct_upload.size
blob.service_headers_for_direct_upload.each_value(&:size)
blob.image? || blob.video?

ActiveStorage::Variant.new(blob, { resize_to_limit: [100, 100] }).download
ActiveStorage::Preview.new(blob, { resize_to_limit: [100, 100] }).download

ActiveStorage::FixtureSet.generate_unique_secure_token(length: 28)
2 changes: 2 additions & 0 deletions gems/activestorage/8.1/_test/test.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class User < ActiveRecord::Base
end
Loading
Loading