1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #42598 from santib/remove-deprecated-methods-active-storage

Remove already deprecated methods in ActiveStorage
This commit is contained in:
Andrew White 2021-06-28 06:55:07 +01:00 committed by GitHub
commit 306449b757
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 5 additions and 43 deletions

View file

@ -1,3 +1,8 @@
* Remove deprecated methods: `build_after_upload`, `create_after_upload!` in favor of `create_and_upload!`,
and `service_url` in favor of `url`.
*Santiago Bartesaghi*
* Add support of `strict_loading_by_default` to `ActiveStorage::Representations` controllers
*Anton Topchii*, *Andrew White*

View file

@ -86,14 +86,6 @@ class ActiveStorage::Blob < ActiveStorage::Record
super(id, purpose: purpose)
end
def build_after_upload(io:, filename:, content_type: nil, metadata: nil, service_name: nil, identify: true, record: nil) #:nodoc:
new(filename: filename, content_type: content_type, metadata: metadata, service_name: service_name).tap do |blob|
blob.upload(io, identify: identify)
end
end
deprecate :build_after_upload
def build_after_unfurling(key: nil, io:, filename:, content_type: nil, metadata: nil, service_name: nil, identify: true, record: nil) #:nodoc:
new(key: key, filename: filename, content_type: content_type, metadata: metadata, service_name: service_name).tap do |blob|
blob.unfurl(io, identify: identify)
@ -115,9 +107,6 @@ class ActiveStorage::Blob < ActiveStorage::Record
end
end
alias_method :create_after_upload!, :create_and_upload!
deprecate create_after_upload!: :create_and_upload!
# Returns a saved blob _without_ uploading a file to the service. This blob will point to a key where there is
# no file yet. It's intended to be used together with a client-side upload, which will first create the blob
# in order to produce the signed URL for uploading. This signed URL points to the key generated by the blob.
@ -208,9 +197,6 @@ class ActiveStorage::Blob < ActiveStorage::Record
content_type: content_type_for_serving, disposition: forced_disposition_for_serving || disposition, **options
end
alias_method :service_url, :url
deprecate service_url: :url
# Returns a URL that can be used to directly upload a file for this blob on the service. This URL is intended to be
# short-lived for security and only generated on-demand by the client-side JavaScript responsible for doing the uploading.
def service_url_for_direct_upload(expires_in: ActiveStorage.service_urls_expire_in)

View file

@ -66,9 +66,6 @@ class ActiveStorage::Preview
end
end
alias_method :service_url, :url
deprecate service_url: :url
# Returns a combination key of the blob and the variation that together identifies a specific variant.
def key
if processed?

View file

@ -79,9 +79,6 @@ class ActiveStorage::Variant
service.url key, expires_in: expires_in, disposition: disposition, filename: filename, content_type: content_type
end
alias_method :service_url, :url
deprecate service_url: :url
# Downloads the file associated with this variant. If no block is given, the entire file is read into memory and returned.
# That'll use a lot of RAM for very large files. If a block is given, then the download is streamed and yielded in chunks.
def download(&block)

View file

@ -29,9 +29,6 @@ class ActiveStorage::VariantWithRecord
delegate :key, :url, :download, to: :image, allow_nil: true
alias_method :service_url, :url
deprecate service_url: :url
private
def transform_blob
blob.open do |input|

View file

@ -32,26 +32,6 @@ class ActiveStorage::BlobTest < ActiveSupport::TestCase
assert_equal data, blob.download
end
test "create_after_upload! has the same effect as create_and_upload!" do
data = "Some other, even more funky file"
blob = assert_deprecated do
ActiveStorage::Blob.create_after_upload!(io: StringIO.new(data), filename: "funky.bin")
end
assert blob.persisted?
assert_equal data, blob.download
end
test "build_after_upload uploads to service but does not save the Blob" do
data = "A potentially overwriting file"
blob = assert_deprecated do
ActiveStorage::Blob.build_after_upload(io: StringIO.new(data), filename: "funky.bin")
end
assert_not blob.persisted?
assert_equal data, blob.download
end
test "create_and_upload sets byte size and checksum" do
data = "Hello world!"
blob = create_blob data: data