From 2a8ce91de9d4294f6e1d095ba57653038fffe832 Mon Sep 17 00:00:00 2001 From: Kasper Timm Hansen Date: Sun, 22 Nov 2015 16:11:28 +0100 Subject: Don't cache fake time zones. When calling `test_time_zone_select_with_priority_zones_as_regexp` it would define `=~` on the fake zones, but it would never be cleaned up because of the zone cache. Nuke it so `test_time_zone_select_with_priority_zones_as_regexp_using_grep_finds_no_zones` accidentally find any zones because of `=~` being implemented. --- actionview/test/template/form_options_helper_test.rb | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'actionview') diff --git a/actionview/test/template/form_options_helper_test.rb b/actionview/test/template/form_options_helper_test.rb index 6eb02bcc03..9d9227bda0 100644 --- a/actionview/test/template/form_options_helper_test.rb +++ b/actionview/test/template/form_options_helper_test.rb @@ -22,17 +22,15 @@ class FormOptionsHelperTest < ActionView::TestCase def to_s; name; end end - ZONES_BY_ID = %w(A B C D E).map { |id| [ id, FakeZone.new(id) ] }.to_h - module ClassMethods - def [](id); use_fake_zones ? ZONES_BY_ID[id] : super(id); end - def all; use_fake_zones ? ZONES_BY_ID.values : super; end + def [](id); fake_zones ? fake_zones[id] : super; end + def all; fake_zones ? fake_zones.values : super; end def dummy; :test; end end def self.prepended(base) class << base - mattr_accessor(:use_fake_zones) { false } + mattr_accessor(:fake_zones) prepend ClassMethods end end @@ -41,12 +39,15 @@ class FormOptionsHelperTest < ActionView::TestCase ActiveSupport::TimeZone.prepend FakeZones setup do - @fake_timezones = FakeZones::ZONES_BY_ID.values - ActiveSupport::TimeZone.use_fake_zones = true + ActiveSupport::TimeZone.fake_zones = %w(A B C D E).map do |id| + [ id, FakeZones::FakeZone.new(id) ] + end.to_h + + @fake_timezones = ActiveSupport::TimeZone.all end teardown do - ActiveSupport::TimeZone.use_fake_zones = false + ActiveSupport::TimeZone.fake_zones = nil end def test_collection_options -- cgit v1.2.3