public
Fork of rails/rails
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/josh/rails.git
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
gbuesing (author)
Thu May 08 21:40:25 -0700 2008
commit  bfbf03ecee063adc9999c0dec50f8177594fb28f
tree    669240ea7fdd60d0366e30ee28348b02c464ab14
parent  66728087d0eb99a524498e8f24725dae6073edd6
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 *SVN*
0
 
0
+* 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 [Geoff Buesing]
0
+
0
 * select_date defaults to Time.zone.today when config.time_zone is set [Geoff Buesing]
0
 
0
 * Fixed that TextHelper#text_field would corrypt when raw HTML was used as the value (mchenryc, Kevin Glowacz) [#80]
...
683
684
685
 
 
686
687
 
688
689
690
691
 
692
693
694
...
683
684
685
686
687
688
 
689
690
691
 
 
692
693
694
695
0
@@ -683,12 +683,13 @@ module ActionView
0
               default[:min] ||= default[:minute]
0
               default[:sec] ||= default[:second]
0
 
0
+ time = Time.current
0
+
0
               [:year, :month, :day, :hour, :min, :sec].each do |key|
0
- default[key] ||= Time.now.send(key)
0
+ default[key] ||= time.send(key)
0
               end
0
 
0
- Time.mktime(default[:year], default[:month], default[:day],
0
- default[:hour], default[:min], default[:sec])
0
+ Time.utc(default[:year], default[:month], default[:day], default[:hour], default[:min], default[:sec])
0
             end
0
         end
0
     end
...
1708
1709
1710
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1711
...
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
0
@@ -1708,4 +1708,27 @@ class DateHelperTest < ActionView::TestCase
0
     assert_dom_equal expected, datetime_select("post", "updated_at", {}, :class => 'selector')
0
   end
0
 
0
+ uses_mocha 'TestInstanceTagDefaultTimeFromOptions' do
0
+ def test_instance_tag_default_time_from_options_uses_time_current_as_default_when_hash_passed_as_arg
0
+ dummy_instance_tag = ActionView::Helpers::InstanceTag.new(1,2,3)
0
+ Time.expects(:current).returns Time.now
0
+ dummy_instance_tag.send!(:default_time_from_options, :hour => 2)
0
+ end
0
+
0
+ def test_instance_tag_default_time_from_options_respects_hash_arg_settings_when_time_falls_in_system_local_dst_spring_gap
0
+ with_env_tz('US/Central') do
0
+ dummy_instance_tag = ActionView::Helpers::InstanceTag.new(1,2,3)
0
+ Time.stubs(:now).returns Time.local(2006, 4, 2, 1)
0
+ assert_equal 2, dummy_instance_tag.send!(:default_time_from_options, :hour => 2).hour
0
+ end
0
+ end
0
+ end
0
+
0
+ protected
0
+ def with_env_tz(new_tz = 'US/Eastern')
0
+ old_tz, ENV['TZ'] = ENV['TZ'], new_tz
0
+ yield
0
+ ensure
0
+ old_tz ? ENV['TZ'] = old_tz : ENV.delete('TZ')
0
+ end
0
 end

Comments

    No one has commented yet.