aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template/date_helper_test.rb
diff options
context:
space:
mode:
authorgbuesing <gbuesing@gmail.com>2008-05-08 23:40:25 -0500
committergbuesing <gbuesing@gmail.com>2008-05-08 23:40:25 -0500
commitbfbf03ecee063adc9999c0dec50f8177594fb28f (patch)
tree669240ea7fdd60d0366e30ee28348b02c464ab14 /actionpack/test/template/date_helper_test.rb
parent66728087d0eb99a524498e8f24725dae6073edd6 (diff)
downloadrails-bfbf03ecee063adc9999c0dec50f8177594fb28f.tar.gz
rails-bfbf03ecee063adc9999c0dec50f8177594fb28f.tar.bz2
rails-bfbf03ecee063adc9999c0dec50f8177594fb28f.zip
ActionView::InstanceTag#default_time_from_options with hash args uses Time.current as default; respects hash settings when time falls in system local spring DST gap
Diffstat (limited to 'actionpack/test/template/date_helper_test.rb')
-rwxr-xr-xactionpack/test/template/date_helper_test.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/actionpack/test/template/date_helper_test.rb b/actionpack/test/template/date_helper_test.rb
index 905cf0ba31..ae83c7bf47 100755
--- a/actionpack/test/template/date_helper_test.rb
+++ b/actionpack/test/template/date_helper_test.rb
@@ -1708,4 +1708,27 @@ class DateHelperTest < ActionView::TestCase
assert_dom_equal expected, datetime_select("post", "updated_at", {}, :class => 'selector')
end
+ uses_mocha 'TestInstanceTagDefaultTimeFromOptions' do
+ def test_instance_tag_default_time_from_options_uses_time_current_as_default_when_hash_passed_as_arg
+ dummy_instance_tag = ActionView::Helpers::InstanceTag.new(1,2,3)
+ Time.expects(:current).returns Time.now
+ dummy_instance_tag.send!(:default_time_from_options, :hour => 2)
+ end
+
+ def test_instance_tag_default_time_from_options_respects_hash_arg_settings_when_time_falls_in_system_local_dst_spring_gap
+ with_env_tz('US/Central') do
+ dummy_instance_tag = ActionView::Helpers::InstanceTag.new(1,2,3)
+ Time.stubs(:now).returns Time.local(2006, 4, 2, 1)
+ assert_equal 2, dummy_instance_tag.send!(:default_time_from_options, :hour => 2).hour
+ end
+ end
+ end
+
+ protected
+ def with_env_tz(new_tz = 'US/Eastern')
+ old_tz, ENV['TZ'] = ENV['TZ'], new_tz
+ yield
+ ensure
+ old_tz ? ENV['TZ'] = old_tz : ENV.delete('TZ')
+ end
end