aboutsummaryrefslogtreecommitdiffstats
path: root/actionview
diff options
context:
space:
mode:
authorKasper Timm Hansen <kaspth@gmail.com>2015-11-22 16:11:28 +0100
committerKasper Timm Hansen <kaspth@gmail.com>2015-11-22 16:11:28 +0100
commit2a8ce91de9d4294f6e1d095ba57653038fffe832 (patch)
treed59bce0fc9d352b84fed80aef8797c97d5de93ee /actionview
parent58910dc7b1805fae777cbc510cf58f625689299c (diff)
downloadrails-2a8ce91de9d4294f6e1d095ba57653038fffe832.tar.gz
rails-2a8ce91de9d4294f6e1d095ba57653038fffe832.tar.bz2
rails-2a8ce91de9d4294f6e1d095ba57653038fffe832.zip
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.
Diffstat (limited to 'actionview')
-rw-r--r--actionview/test/template/form_options_helper_test.rb17
1 files changed, 9 insertions, 8 deletions
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