Skip to content

Commit

Permalink
Remove deprecated ActiveStorage::Current#host and `ActiveStorage::C…
Browse files Browse the repository at this point in the history
…urrent#host=` methods
  • Loading branch information
rafaelfranca committed Mar 3, 2023
1 parent 4edaa41 commit 0591de5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
4 changes: 4 additions & 0 deletions activestorage/CHANGELOG.md
@@ -1,3 +1,7 @@
* Remove deprecated `ActiveStorage::Current#host` and `ActiveStorage::Current#host=` methods.

*Rafael Mendonça França*

* Remove deprecated invalid default content types in Active Storage configurations.

*Rafael Mendonça França*
Expand Down
10 changes: 0 additions & 10 deletions activestorage/app/models/active_storage/current.rb
Expand Up @@ -2,14 +2,4 @@

class ActiveStorage::Current < ActiveSupport::CurrentAttributes # :nodoc:
attribute :url_options

def host=(host)
ActiveStorage.deprecator.warn("ActiveStorage::Current.host= is deprecated, instead use ActiveStorage::Current.url_options=")
self.url_options = { host: host }
end

def host
ActiveStorage.deprecator.warn("ActiveStorage::Current.host is deprecated, instead use ActiveStorage::Current.url_options")
self.url_options&.dig(:host)
end
end
3 changes: 1 addition & 2 deletions activestorage/test/service/disk_service_test.rb
Expand Up @@ -50,8 +50,7 @@ class ActiveStorage::Service::DiskServiceTest < ActiveSupport::TestCase
end

test "URL generation keeps working with ActiveStorage::Current.host set" do
ActiveStorage::Current.url_options = nil
assert_deprecated(ActiveStorage.deprecator) { ActiveStorage::Current.host = "https://example.com" }
ActiveStorage::Current.url_options = { host: "https://example.com" }

original_url_options = Rails.application.routes.default_url_options.dup
Rails.application.routes.default_url_options.merge!(protocol: "http", host: "test.example.com", port: 3001)
Expand Down
2 changes: 2 additions & 0 deletions guides/source/7_1_release_notes.md
Expand Up @@ -122,6 +122,8 @@ Please refer to the [Changelog][active-storage] for detailed changes.

* Remove deprecated invalid default content types in Active Storage configurations.

* Remove deprecated `ActiveStorage::Current#host` and `ActiveStorage::Current#host=` methods.

### Deprecations

### Notable changes
Expand Down

0 comments on commit 0591de5

Please sign in to comment.