mirror of https://github.com/rails/rails
Allow to opt-in to the new TimeWithZone.name and fix XmlMini serialization
This commit is contained in:
parent
b171b842da
commit
3457a4676d
|
@ -9,6 +9,13 @@ module ActiveSupport
|
||||||
|
|
||||||
config.eager_load_namespaces << ActiveSupport
|
config.eager_load_namespaces << ActiveSupport
|
||||||
|
|
||||||
|
initializer "active_support.remove_deprecated_time_with_zone_name" do |app|
|
||||||
|
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
|
||||||
|
|
||||||
initializer "active_support.set_authenticated_message_encryption" do |app|
|
initializer "active_support.set_authenticated_message_encryption" do |app|
|
||||||
config.after_initialize do
|
config.after_initialize do
|
||||||
unless app.config.active_support.use_authenticated_message_encryption.nil?
|
unless app.config.active_support.use_authenticated_message_encryption.nil?
|
||||||
|
|
|
@ -45,6 +45,8 @@ module ActiveSupport
|
||||||
ActiveSupport::Deprecation.warn(<<~EOM)
|
ActiveSupport::Deprecation.warn(<<~EOM)
|
||||||
ActiveSupport::TimeWithZone.name has been deprecated and
|
ActiveSupport::TimeWithZone.name has been deprecated and
|
||||||
from Rails 7.1 will use the default Ruby implementation.
|
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 thew new behavior now.
|
||||||
EOM
|
EOM
|
||||||
|
|
||||||
"Time"
|
"Time"
|
||||||
|
|
|
@ -50,6 +50,7 @@ module ActiveSupport
|
||||||
"Hash" => "hash"
|
"Hash" => "hash"
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
TYPE_NAMES["ActiveSupport::TimeWithZone"] = TYPE_NAMES["Time"]
|
||||||
|
|
||||||
FORMATTING = {
|
FORMATTING = {
|
||||||
"symbol" => Proc.new { |symbol| symbol.to_s },
|
"symbol" => Proc.new { |symbol| symbol.to_s },
|
||||||
|
|
|
@ -134,6 +134,14 @@ module XmlMiniTest
|
||||||
assert_xml("<b type=\"dateTime\">1993-02-24T12:00:00+09:00</b>")
|
assert_xml("<b type=\"dateTime\">1993-02-24T12:00:00+09:00</b>")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "#to_tag accepts ActiveSupport::TimeWithZone types" do
|
||||||
|
time = ActiveSupport::TimeWithZone.new(Time.new(1993, 02, 24, 12, 0, 0, "+09:00"), ActiveSupport::TimeZone["Europe/Paris"])
|
||||||
|
ActiveSupport::TimeWithZone.stub(:name, "ActiveSupport::TimeWithZone") do
|
||||||
|
@xml.to_tag(:b, time, @options)
|
||||||
|
assert_xml("<b type=\"dateTime\">1993-02-24T13:00:00+01:00</b>")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
test "#to_tag accepts array types" do
|
test "#to_tag accepts array types" do
|
||||||
@xml.to_tag(:b, ["first_name", "last_name"], @options)
|
@xml.to_tag(:b, ["first_name", "last_name"], @options)
|
||||||
assert_xml("<b type=\"array\"><b>first_name</b><b>last_name</b></b>")
|
assert_xml("<b type=\"array\"><b>first_name</b><b>last_name</b></b>")
|
||||||
|
|
|
@ -209,6 +209,7 @@ module Rails
|
||||||
if respond_to?(:active_support)
|
if respond_to?(:active_support)
|
||||||
active_support.hash_digest_class = OpenSSL::Digest::SHA256
|
active_support.hash_digest_class = OpenSSL::Digest::SHA256
|
||||||
active_support.key_generator_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
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
raise "Unknown version #{target_version.to_s.inspect}"
|
raise "Unknown version #{target_version.to_s.inspect}"
|
||||||
|
|
Loading…
Reference in New Issue