Skip to content

Commit 306449b

Browse files
authored
Merge pull request rails#42598 from santib/remove-deprecated-methods-active-storage
Remove already deprecated methods in ActiveStorage
2 parents f73b777 + 65b1e1b commit 306449b

File tree

6 files changed

+5
-43
lines changed

6 files changed

+5
-43
lines changed

activestorage/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
* Remove deprecated methods: `build_after_upload`, `create_after_upload!` in favor of `create_and_upload!`,
2+
and `service_url` in favor of `url`.
3+
4+
*Santiago Bartesaghi*
5+
16
* Add support of `strict_loading_by_default` to `ActiveStorage::Representations` controllers
27

38
*Anton Topchii*, *Andrew White*

activestorage/app/models/active_storage/blob.rb

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,6 @@ def find_signed!(id, record: nil, purpose: :blob_id)
8686
super(id, purpose: purpose)
8787
end
8888

89-
def build_after_upload(io:, filename:, content_type: nil, metadata: nil, service_name: nil, identify: true, record: nil) #:nodoc:
90-
new(filename: filename, content_type: content_type, metadata: metadata, service_name: service_name).tap do |blob|
91-
blob.upload(io, identify: identify)
92-
end
93-
end
94-
95-
deprecate :build_after_upload
96-
9789
def build_after_unfurling(key: nil, io:, filename:, content_type: nil, metadata: nil, service_name: nil, identify: true, record: nil) #:nodoc:
9890
new(key: key, filename: filename, content_type: content_type, metadata: metadata, service_name: service_name).tap do |blob|
9991
blob.unfurl(io, identify: identify)
@@ -115,9 +107,6 @@ def create_and_upload!(key: nil, io:, filename:, content_type: nil, metadata: ni
115107
end
116108
end
117109

118-
alias_method :create_after_upload!, :create_and_upload!
119-
deprecate create_after_upload!: :create_and_upload!
120-
121110
# Returns a saved blob _without_ uploading a file to the service. This blob will point to a key where there is
122111
# no file yet. It's intended to be used together with a client-side upload, which will first create the blob
123112
# in order to produce the signed URL for uploading. This signed URL points to the key generated by the blob.
@@ -208,9 +197,6 @@ def url(expires_in: ActiveStorage.service_urls_expire_in, disposition: :inline,
208197
content_type: content_type_for_serving, disposition: forced_disposition_for_serving || disposition, **options
209198
end
210199

211-
alias_method :service_url, :url
212-
deprecate service_url: :url
213-
214200
# Returns a URL that can be used to directly upload a file for this blob on the service. This URL is intended to be
215201
# short-lived for security and only generated on-demand by the client-side JavaScript responsible for doing the uploading.
216202
def service_url_for_direct_upload(expires_in: ActiveStorage.service_urls_expire_in)

activestorage/app/models/active_storage/preview.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@ def url(**options)
6666
end
6767
end
6868

69-
alias_method :service_url, :url
70-
deprecate service_url: :url
71-
7269
# Returns a combination key of the blob and the variation that together identifies a specific variant.
7370
def key
7471
if processed?

activestorage/app/models/active_storage/variant.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ def url(expires_in: ActiveStorage.service_urls_expire_in, disposition: :inline)
7979
service.url key, expires_in: expires_in, disposition: disposition, filename: filename, content_type: content_type
8080
end
8181

82-
alias_method :service_url, :url
83-
deprecate service_url: :url
84-
8582
# Downloads the file associated with this variant. If no block is given, the entire file is read into memory and returned.
8683
# 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.
8784
def download(&block)

activestorage/app/models/active_storage/variant_with_record.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ def image
2929

3030
delegate :key, :url, :download, to: :image, allow_nil: true
3131

32-
alias_method :service_url, :url
33-
deprecate service_url: :url
34-
3532
private
3633
def transform_blob
3734
blob.open do |input|

activestorage/test/models/blob_test.rb

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,6 @@ class ActiveStorage::BlobTest < ActiveSupport::TestCase
3232
assert_equal data, blob.download
3333
end
3434

35-
test "create_after_upload! has the same effect as create_and_upload!" do
36-
data = "Some other, even more funky file"
37-
blob = assert_deprecated do
38-
ActiveStorage::Blob.create_after_upload!(io: StringIO.new(data), filename: "funky.bin")
39-
end
40-
41-
assert blob.persisted?
42-
assert_equal data, blob.download
43-
end
44-
45-
test "build_after_upload uploads to service but does not save the Blob" do
46-
data = "A potentially overwriting file"
47-
blob = assert_deprecated do
48-
ActiveStorage::Blob.build_after_upload(io: StringIO.new(data), filename: "funky.bin")
49-
end
50-
51-
assert_not blob.persisted?
52-
assert_equal data, blob.download
53-
end
54-
5535
test "create_and_upload sets byte size and checksum" do
5636
data = "Hello world!"
5737
blob = create_blob data: data

0 commit comments

Comments
 (0)