提交 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
# The love zone is UTC+0
mytz = Class.new(ActiveSupport::TimeZone) {
attr_accessor :now
}.create('tenderlove', 0)
}.create('tenderlove', 0, ActiveSupport::TimeZone.find_tzinfo('UTC'))
now = Time.mktime(2004, 6, 15, 16, 35, 0)
mytz.now = now
......
......@@ -202,7 +202,7 @@ def seconds_to_utc_offset(seconds, colon = true)
end
def find_tzinfo(name)
TZInfo::TimezoneProxy.new(MAPPING[name] || name)
TZInfo::Timezone.new(MAPPING[name] || name)
end
alias_method :create, :new
......@@ -237,7 +237,7 @@ def [](arg)
case arg
when String
begin
@lazy_zones_map[arg] ||= create(arg).tap(&:utc_offset)
@lazy_zones_map[arg] ||= create(arg)
rescue TZInfo::InvalidTimezoneIdentifier
nil
end
......
......@@ -395,15 +395,10 @@ def test_index
assert_raise(ArgumentError) { ActiveSupport::TimeZone[false] }
end
def test_unknown_zone_should_have_tzinfo_but_exception_on_utc_offset
zone = ActiveSupport::TimeZone.create("bogus")
assert_instance_of TZInfo::TimezoneProxy, zone.tzinfo
assert_raise(TZInfo::InvalidTimezoneIdentifier) { zone.utc_offset }
end
def test_unknown_zone_with_utc_offset
zone = ActiveSupport::TimeZone.create("bogus", -21_600)
assert_equal(-21_600, zone.utc_offset)
def test_unknown_zone_raises_exception
assert_raise TZInfo::InvalidTimezoneIdentifier do
ActiveSupport::TimeZone.create("bogus")
end
end
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.
先完成此消息的编辑!
想要评论请 注册