aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorgbuesing <gbuesing@gmail.com>2008-05-08 22:48:47 -0500
committergbuesing <gbuesing@gmail.com>2008-05-08 22:48:47 -0500
commit66728087d0eb99a524498e8f24725dae6073edd6 (patch)
treee8675936450de56cc4603d9057668cc365ae7113 /actionpack
parent79e44a5ee484f977c2cad8a4cffe882b816340a1 (diff)
downloadrails-66728087d0eb99a524498e8f24725dae6073edd6.tar.gz
rails-66728087d0eb99a524498e8f24725dae6073edd6.tar.bz2
rails-66728087d0eb99a524498e8f24725dae6073edd6.zip
Adding Date.current, which returns Time.zone.today if config.time_zone is set; otherwise returns Date.today. ActionView date_helper uses Date.current to determine locale-appropriate default
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/CHANGELOG2
-rwxr-xr-xactionpack/lib/action_view/helpers/date_helper.rb2
-rwxr-xr-xactionpack/test/template/date_helper_test.rb9
3 files changed, 12 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 54030047ba..438fa24c75 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* select_date defaults to Time.zone.today when config.time_zone is set [Geoff Buesing]
+
* Fixed that TextHelper#text_field would corrypt when raw HTML was used as the value (mchenryc, Kevin Glowacz) [#80]
* Added ActionController::TestCase#rescue_action_in_public! to control whether the action under test should use the regular rescue_action path instead of simply raising the exception inline (great for error testing) [DHH]
diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb
index cbd390421a..542ef3ef65 100755
--- a/actionpack/lib/action_view/helpers/date_helper.rb
+++ b/actionpack/lib/action_view/helpers/date_helper.rb
@@ -283,7 +283,7 @@ module ActionView
# # prefixed with 'payday' rather than 'date'
# select_datetime(my_date_time, :prefix => 'payday')
#
- def select_date(date = Date.today, options = {}, html_options = {})
+ def select_date(date = Date.current, options = {}, html_options = {})
options[:order] ||= []
[:year, :month, :day].each { |o| options[:order].push(o) unless options[:order].include?(o) }
diff --git a/actionpack/test/template/date_helper_test.rb b/actionpack/test/template/date_helper_test.rb
index 2373600bfe..905cf0ba31 100755
--- a/actionpack/test/template/date_helper_test.rb
+++ b/actionpack/test/template/date_helper_test.rb
@@ -950,6 +950,15 @@ class DateHelperTest < ActionView::TestCase
expects(:select_minute).with(time, anything, anything).returns('')
select_time
end
+
+ def test_select_date_uses_date_current_as_default
+ date = stub(:year => 2004, :month => 6, :day => 15)
+ Date.expects(:current).returns date
+ expects(:select_year).with(date, anything, anything).returns('')
+ expects(:select_month).with(date, anything, anything).returns('')
+ expects(:select_day).with(date, anything, anything).returns('')
+ select_date
+ end
end
def test_date_select