From 5c73f0d398d2a7ed955040e580374e92d6536283 Mon Sep 17 00:00:00 2001 From: Brian McManus Date: Tue, 19 Feb 2013 17:51:23 -0800 Subject: Fix time_zone_options_for_select to not mutate TimeZones array Previous implementation of time_zone_options_for_select did not dup the ActiveSupport::TimeZone.all array. When :priority_zones were provided the method would reject! the zones from the memoized TimeZones array thus affecting future requests to the server. Essentially whatever zones were specified as :priority_zones would show up for the first request but then disappear from the time zone options on future requests. --- actionpack/test/template/form_options_helper_test.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'actionpack/test') diff --git a/actionpack/test/template/form_options_helper_test.rb b/actionpack/test/template/form_options_helper_test.rb index c5efed3195..757b05dbc1 100644 --- a/actionpack/test/template/form_options_helper_test.rb +++ b/actionpack/test/template/form_options_helper_test.rb @@ -416,6 +416,13 @@ class FormOptionsHelperTest < ActionView::TestCase "", opts end + + def test_time_zone_options_with_priority_zones_does_not_mutate_time_zones + original_zones = ActiveSupport::TimeZone.all.dup + zones = [ ActiveSupport::TimeZone.new( "B" ), ActiveSupport::TimeZone.new( "E" ) ] + opts = time_zone_options_for_select( nil, zones ) + assert_equal original_zones, ActiveSupport::TimeZone.all + end def test_time_zone_options_returns_html_safe_string assert time_zone_options_for_select.html_safe? -- cgit v1.2.3