mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Make ActiveSupport::TimeZone.all independent of previous lookups (#31176)
This commit is contained in:
parent
858baa099b
commit
078421bacb
3 changed files with 23 additions and 3 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
* Make `ActiveSupport::TimeZone.all` return only time zones that are in
|
||||||
|
`ActiveSupport::TimeZone::MAPPING`.
|
||||||
|
|
||||||
|
Fixes #7245.
|
||||||
|
|
||||||
|
*Chris LaRose*
|
||||||
|
|
||||||
* MemCacheStore: Support expiring counters.
|
* MemCacheStore: Support expiring counters.
|
||||||
|
|
||||||
Pass `expires_in: [seconds]` to `#increment` and `#decrement` options
|
Pass `expires_in: [seconds]` to `#increment` and `#decrement` options
|
||||||
|
|
|
@ -256,6 +256,13 @@ module ActiveSupport
|
||||||
@country_zones[code] ||= load_country_zones(code)
|
@country_zones[code] ||= load_country_zones(code)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def clear() #:nodoc:
|
||||||
|
@lazy_zones_map = Concurrent::Map.new
|
||||||
|
@country_zones = Concurrent::Map.new
|
||||||
|
@zones = nil
|
||||||
|
@zones_map = nil
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def load_country_zones(code)
|
def load_country_zones(code)
|
||||||
country = TZInfo::Country.get(code)
|
country = TZInfo::Country.get(code)
|
||||||
|
@ -269,9 +276,8 @@ module ActiveSupport
|
||||||
end
|
end
|
||||||
|
|
||||||
def zones_map
|
def zones_map
|
||||||
@zones_map ||= begin
|
@zones_map ||= MAPPING.each_with_object({}) do |(name, _), zones|
|
||||||
MAPPING.each_key { |place| self[place] } # load all the zones
|
zones[name] = self[name]
|
||||||
@lazy_zones_map
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -718,6 +718,13 @@ class TimeZoneTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_all_uninfluenced_by_time_zone_lookups_delegated_to_tzinfo
|
||||||
|
ActiveSupport::TimeZone.clear
|
||||||
|
galapagos = ActiveSupport::TimeZone["Pacific/Galapagos"]
|
||||||
|
all_zones = ActiveSupport::TimeZone.all
|
||||||
|
assert_not_includes all_zones, galapagos
|
||||||
|
end
|
||||||
|
|
||||||
def test_index
|
def test_index
|
||||||
assert_nil ActiveSupport::TimeZone["bogus"]
|
assert_nil ActiveSupport::TimeZone["bogus"]
|
||||||
assert_instance_of ActiveSupport::TimeZone, ActiveSupport::TimeZone["Central Time (US & Canada)"]
|
assert_instance_of ActiveSupport::TimeZone, ActiveSupport::TimeZone["Central Time (US & Canada)"]
|
||||||
|
|
Loading…
Reference in a new issue