Remove deprecated override of ActiveSupport::TimeWithZone.name
This commit is contained in:
parent
e420c3380e
commit
34e296d492
@ -1,3 +1,11 @@
|
||||
* Deprecate `config.active_support.remove_deprecated_time_with_zone_name`.
|
||||
|
||||
*Rafael Mendonça França*
|
||||
|
||||
* Remove deprecated override of `ActiveSupport::TimeWithZone.name`.
|
||||
|
||||
*Rafael Mendonça França*
|
||||
|
||||
* Deprecate `config.active_support.disable_to_s_conversion`.
|
||||
|
||||
*Rafael Mendonça França*
|
||||
|
@ -29,15 +29,6 @@ class Railtie < Rails::Railtie # :nodoc:
|
||||
end
|
||||
end
|
||||
|
||||
initializer "active_support.remove_deprecated_time_with_zone_name" do |app|
|
||||
config.after_initialize do
|
||||
if app.config.active_support.remove_deprecated_time_with_zone_name
|
||||
require "active_support/time_with_zone"
|
||||
TimeWithZone.singleton_class.remove_method(:name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
initializer "active_support.set_authenticated_message_encryption" do |app|
|
||||
config.after_initialize do
|
||||
unless app.config.active_support.use_authenticated_message_encryption.nil?
|
||||
@ -128,6 +119,8 @@ class Railtie < Rails::Railtie # :nodoc:
|
||||
app.config.active_support.each do |k, v|
|
||||
if k == "disable_to_s_conversion"
|
||||
ActiveSupport.deprecator.warn("config.active_support.disable_to_s_conversion is deprecated and will be removed in Rails 7.2.")
|
||||
elsif k == "remove_deprecated_time_with_zone_name"
|
||||
ActiveSupport.deprecator.warn("config.active_support.remove_deprecated_time_with_zone_name is deprecated and will be removed in Rails 7.2.")
|
||||
else
|
||||
k = "#{k}="
|
||||
ActiveSupport.public_send(k, v) if ActiveSupport.respond_to? k
|
||||
|
@ -40,18 +40,6 @@ module ActiveSupport
|
||||
# t.is_a?(Time) # => true
|
||||
# t.is_a?(ActiveSupport::TimeWithZone) # => true
|
||||
class TimeWithZone
|
||||
# Report class name as 'Time' to thwart type checking.
|
||||
def self.name
|
||||
ActiveSupport.deprecator.warn(<<~EOM)
|
||||
ActiveSupport::TimeWithZone.name has been deprecated and
|
||||
from Rails 7.1 will use the default Ruby implementation.
|
||||
You can set `config.active_support.remove_deprecated_time_with_zone_name = true`
|
||||
to enable the new behavior now.
|
||||
EOM
|
||||
|
||||
"Time"
|
||||
end
|
||||
|
||||
PRECISIONS = Hash.new { |h, n| h[n] = "%FT%T.%#{n}N" }
|
||||
PRECISIONS[0] = "%FT%T"
|
||||
|
||||
|
@ -584,19 +584,6 @@ def test_three_levels_with_array
|
||||
assert_includes xml, %(<addresses type="array"><address><streets type="array"><street><name>)
|
||||
end
|
||||
|
||||
def test_timezoned_attributes
|
||||
# TODO: Remove assertion in Rails 7.1 and add ActiveSupport::TimeWithZone to XML type mapping
|
||||
assert_deprecated("ActiveSupport::TimeWithZone.name has been deprecated", ActiveSupport.deprecator) do
|
||||
xml = {
|
||||
created_at: Time.utc(1999, 2, 2),
|
||||
local_created_at: Time.utc(1999, 2, 2).in_time_zone("Eastern Time (US & Canada)")
|
||||
}.to_xml(@xml_options)
|
||||
|
||||
assert_match %r{<created-at type="dateTime">1999-02-02T00:00:00Z</created-at>}, xml
|
||||
assert_match %r{<local-created-at type="dateTime">1999-02-01T19:00:00-05:00</local-created-at>}, xml
|
||||
end
|
||||
end
|
||||
|
||||
def test_multiple_records_from_xml_with_attributes_other_than_type_ignores_them_without_exploding
|
||||
topics_xml = <<-EOT
|
||||
<topics type="array" page="1" page-count="1000" per-page="2">
|
||||
|
@ -579,13 +579,6 @@ def test_is_a
|
||||
assert_kind_of ActiveSupport::TimeWithZone, @twz
|
||||
end
|
||||
|
||||
def test_class_name
|
||||
# TODO: Remove assertion in Rails 7.1 and change expected value
|
||||
assert_deprecated("ActiveSupport::TimeWithZone.name has been deprecated", ActiveSupport.deprecator) do
|
||||
assert_equal "Time", ActiveSupport::TimeWithZone.name
|
||||
end
|
||||
end
|
||||
|
||||
def test_method_missing_with_time_return_value
|
||||
assert_instance_of ActiveSupport::TimeWithZone, @twz.months_since(1)
|
||||
assert_equal Time.utc(2000, 1, 31, 19, 0, 0), @twz.months_since(1).time
|
||||
|
@ -145,10 +145,14 @@ Please refer to the [Changelog][active-support] for detailed changes.
|
||||
* Remove deprecated option to passing a format to `#to_s` in `Array`, `Range`, `Date`, `DateTime`, `Time`,
|
||||
`BigDecimal`, `Float` and, `Integer`.
|
||||
|
||||
* Remove deprecated override of `ActiveSupport::TimeWithZone.name`.
|
||||
|
||||
### Deprecations
|
||||
|
||||
* Deprecate `config.active_support.disable_to_s_conversion`.
|
||||
|
||||
* Deprecate `config.active_support.remove_deprecated_time_with_zone_name`.
|
||||
|
||||
### Notable changes
|
||||
|
||||
Active Job
|
||||
|
@ -100,7 +100,6 @@ Below are the default values associated with each target version. In cases of co
|
||||
- [`config.active_support.hash_digest_class`](#config-active-support-hash-digest-class): `OpenSSL::Digest::SHA256`
|
||||
- [`config.active_support.isolation_level`](#config-active-support-isolation-level): `:thread`
|
||||
- [`config.active_support.key_generator_hash_digest_class`](#config-active-support-key-generator-hash-digest-class): `OpenSSL::Digest::SHA256`
|
||||
- [`config.active_support.remove_deprecated_time_with_zone_name`](#config-active-support-remove-deprecated-time-with-zone-name): `true`
|
||||
- [`config.active_support.use_rfc4122_namespaced_uuids`](#config-active-support-use-rfc4122-namespaced-uuids): `true`
|
||||
|
||||
#### Default Values for Target Version 6.1
|
||||
@ -2270,17 +2269,6 @@ When `false`, disables all deprecation warnings, including disallowed deprecatio
|
||||
|
||||
In the default generated `config/environments` files, this is set to `false` for production.
|
||||
|
||||
#### `config.active_support.remove_deprecated_time_with_zone_name`
|
||||
|
||||
Specifies whether to remove the deprecated override of the [`ActiveSupport::TimeWithZone.name`](https://api.rubyonrails.org/classes/ActiveSupport/TimeWithZone.html#method-c-name) method, to avoid triggering its deprecation warning.
|
||||
|
||||
The default value depends on the `config.load_defaults` target version:
|
||||
|
||||
| Starting with version | The default value is |
|
||||
| --------------------- | -------------------- |
|
||||
| (original) | `nil` |
|
||||
| 7.0 | `true` |
|
||||
|
||||
#### `config.active_support.isolation_level`
|
||||
|
||||
Configures the locality of most of Rails internal state. If you use a fiber based server or job processor (e.g. `falcon`), you should set it to `:fiber`. Otherwise it is best to use `:thread` locality. Defaults to `:thread`.
|
||||
|
@ -237,7 +237,6 @@ def load_defaults(target_version)
|
||||
if respond_to?(:active_support)
|
||||
active_support.hash_digest_class = OpenSSL::Digest::SHA256
|
||||
active_support.key_generator_hash_digest_class = OpenSSL::Digest::SHA256
|
||||
active_support.remove_deprecated_time_with_zone_name = true
|
||||
active_support.cache_format_version = 7.0
|
||||
active_support.use_rfc4122_namespaced_uuids = true
|
||||
active_support.executor_around_test_case = true
|
||||
|
@ -4005,23 +4005,6 @@ def new(app); self; end
|
||||
assert_nil Rails.application.config.middleware.map(&:name).index("3rd custom middleware")
|
||||
end
|
||||
|
||||
test "ActiveSupport::TimeWithZone.name uses default Ruby implementation by default" do
|
||||
app "development"
|
||||
assert_equal false, ActiveSupport::TimeWithZone.methods(false).include?(:name)
|
||||
end
|
||||
|
||||
test "ActiveSupport::TimeWithZone.name can be configured in the new framework defaults" do
|
||||
remove_from_config '.*config\.load_defaults.*\n'
|
||||
|
||||
app_file "config/initializers/new_framework_defaults_7_0.rb", <<-RUBY
|
||||
Rails.application.config.active_support.remove_deprecated_time_with_zone_name = false
|
||||
RUBY
|
||||
|
||||
app "development"
|
||||
|
||||
assert_equal true, ActiveSupport::TimeWithZone.methods(false).include?(:name)
|
||||
end
|
||||
|
||||
test "Rails.application.deprecators includes framework deprecators" do
|
||||
app "production"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user