提交 9644cdcd 编写于 作者: R Rafael Mendonça França

Merge pull request #18328 from brainopia/remove_tz_proxy

Use directly TZInfo::Timezone without proxy
...@@ -2330,7 +2330,7 @@ def test_datetime_select_defaults_to_time_zone_now_when_config_time_zone_is_set ...@@ -2330,7 +2330,7 @@ def test_datetime_select_defaults_to_time_zone_now_when_config_time_zone_is_set
# The love zone is UTC+0 # The love zone is UTC+0
mytz = Class.new(ActiveSupport::TimeZone) { mytz = Class.new(ActiveSupport::TimeZone) {
attr_accessor :now attr_accessor :now
}.create('tenderlove', 0) }.create('tenderlove', 0, ActiveSupport::TimeZone.find_tzinfo('UTC'))
now = Time.mktime(2004, 6, 15, 16, 35, 0) now = Time.mktime(2004, 6, 15, 16, 35, 0)
mytz.now = now mytz.now = now
......
...@@ -202,7 +202,7 @@ def seconds_to_utc_offset(seconds, colon = true) ...@@ -202,7 +202,7 @@ def seconds_to_utc_offset(seconds, colon = true)
end end
def find_tzinfo(name) def find_tzinfo(name)
TZInfo::TimezoneProxy.new(MAPPING[name] || name) TZInfo::Timezone.new(MAPPING[name] || name)
end end
alias_method :create, :new alias_method :create, :new
...@@ -237,7 +237,7 @@ def [](arg) ...@@ -237,7 +237,7 @@ def [](arg)
case arg case arg
when String when String
begin begin
@lazy_zones_map[arg] ||= create(arg).tap(&:utc_offset) @lazy_zones_map[arg] ||= create(arg)
rescue TZInfo::InvalidTimezoneIdentifier rescue TZInfo::InvalidTimezoneIdentifier
nil nil
end end
......
...@@ -395,15 +395,10 @@ def test_index ...@@ -395,15 +395,10 @@ def test_index
assert_raise(ArgumentError) { ActiveSupport::TimeZone[false] } assert_raise(ArgumentError) { ActiveSupport::TimeZone[false] }
end end
def test_unknown_zone_should_have_tzinfo_but_exception_on_utc_offset def test_unknown_zone_raises_exception
zone = ActiveSupport::TimeZone.create("bogus") assert_raise TZInfo::InvalidTimezoneIdentifier do
assert_instance_of TZInfo::TimezoneProxy, zone.tzinfo ActiveSupport::TimeZone.create("bogus")
assert_raise(TZInfo::InvalidTimezoneIdentifier) { zone.utc_offset } end
end
def test_unknown_zone_with_utc_offset
zone = ActiveSupport::TimeZone.create("bogus", -21_600)
assert_equal(-21_600, zone.utc_offset)
end end
def test_unknown_zones_dont_store_mapping_keys def test_unknown_zones_dont_store_mapping_keys
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册