aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorAndrew White <andrew.white@unboxed.co>2018-02-19 10:24:13 +0000
committerAndrew White <andrew.white@unboxed.co>2018-02-19 10:37:35 +0000
commit2d95956e8b564236f0c5f98ea18d8535b05344f0 (patch)
tree4f4833dddfe790d4832ed5a1c12311ab54e93da0 /activesupport/test
parentf712ef27c55fc4210a722d447e05271adef1e57f (diff)
downloadrails-2d95956e8b564236f0c5f98ea18d8535b05344f0.tar.gz
rails-2d95956e8b564236f0c5f98ea18d8535b05344f0.tar.bz2
rails-2d95956e8b564236f0c5f98ea18d8535b05344f0.zip
Return all mappings for a timezone id in `country_zones`
Some timezones like `Europe/London` have multiple mappings in `ActiveSupport::TimeZone::MAPPING` so return all of them instead of the first one found by using `Hash#value`. e.g: # Before ActiveSupport::TimeZone.country_zones("GB") # => ["Edinburgh"] # After ActiveSupport::TimeZone.country_zones("GB") # => ["Edinburgh", "London"] Fixes #31668.
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/time_zone_test.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activesupport/test/time_zone_test.rb b/activesupport/test/time_zone_test.rb
index 405c8f315b..63ca22efb5 100644
--- a/activesupport/test/time_zone_test.rb
+++ b/activesupport/test/time_zone_test.rb
@@ -756,6 +756,16 @@ class TimeZoneTest < ActiveSupport::TestCase
assert_not_includes ActiveSupport::TimeZone.country_zones(:ru), ActiveSupport::TimeZone["Kuala Lumpur"]
end
+ def test_country_zones_with_and_without_mappings
+ assert_includes ActiveSupport::TimeZone.country_zones("au"), ActiveSupport::TimeZone["Adelaide"]
+ assert_includes ActiveSupport::TimeZone.country_zones("au"), ActiveSupport::TimeZone["Australia/Lord_Howe"]
+ end
+
+ def test_country_zones_with_multiple_mappings
+ assert_includes ActiveSupport::TimeZone.country_zones("gb"), ActiveSupport::TimeZone["Edinburgh"]
+ assert_includes ActiveSupport::TimeZone.country_zones("gb"), ActiveSupport::TimeZone["London"]
+ end
+
def test_country_zones_without_mappings
assert_includes ActiveSupport::TimeZone.country_zones(:sv), ActiveSupport::TimeZone["America/El_Salvador"]
end