aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/time_zone_test_helpers.rb
diff options
context:
space:
mode:
authorAndrew White <pixeltrix@users.noreply.github.com>2018-04-19 09:25:02 +0100
committerGitHub <noreply@github.com>2018-04-19 09:25:02 +0100
commitb6577cb62880a88380fce6a086a1c084d5a74c18 (patch)
tree9ea30543b6b2f68f15d9c0b711054ee035a4b8fe /activesupport/test/time_zone_test_helpers.rb
parentef2af628a9ec1cc4e7b6997a021dd3f85cfe4665 (diff)
parentfb2af6f849c8d25732f2c17352c59f2dc8b8320d (diff)
downloadrails-b6577cb62880a88380fce6a086a1c084d5a74c18.tar.gz
rails-b6577cb62880a88380fce6a086a1c084d5a74c18.tar.bz2
rails-b6577cb62880a88380fce6a086a1c084d5a74c18.zip
Merge pull request #32613 from dsander/fix-as-timezone-all
Fix exception in AS::Timezone.all when any tzinfo data is missing
Diffstat (limited to 'activesupport/test/time_zone_test_helpers.rb')
-rw-r--r--activesupport/test/time_zone_test_helpers.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/activesupport/test/time_zone_test_helpers.rb b/activesupport/test/time_zone_test_helpers.rb
index 051703a781..85ed727c9b 100644
--- a/activesupport/test/time_zone_test_helpers.rb
+++ b/activesupport/test/time_zone_test_helpers.rb
@@ -23,4 +23,17 @@ module TimeZoneTestHelpers
ensure
ActiveSupport.to_time_preserves_timezone = old_preserve_tz
end
+
+ def with_tz_mappings(mappings)
+ old_mappings = ActiveSupport::TimeZone::MAPPING.dup
+ ActiveSupport::TimeZone.clear
+ ActiveSupport::TimeZone::MAPPING.clear
+ ActiveSupport::TimeZone::MAPPING.merge!(mappings)
+
+ yield
+ ensure
+ ActiveSupport::TimeZone.clear
+ ActiveSupport::TimeZone::MAPPING.clear
+ ActiveSupport::TimeZone::MAPPING.merge!(old_mappings)
+ end
end