From a1e1fd8d6179afa1d8df058b66b83fb19a3b9a43 Mon Sep 17 00:00:00 2001 From: Sam Oliver Date: Fri, 2 Jan 2009 15:34:38 +0000 Subject: [PATCH] Stops date select helpers from defaulting the selected date to today if :prompt option has been used --- actionpack/lib/action_view/helpers/date_helper.rb | 2 +- actionpack/test/template/date_helper_test.rb | 28 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb index 4305617..56245cd 100644 --- a/actionpack/lib/action_view/helpers/date_helper.rb +++ b/actionpack/lib/action_view/helpers/date_helper.rb @@ -931,7 +931,7 @@ module ActionView end def default_datetime(options) - return if options[:include_blank] + return if options[:include_blank] || options[:prompt] case options[:default] when nil diff --git a/actionpack/test/template/date_helper_test.rb b/actionpack/test/template/date_helper_test.rb index 6ec01b7..2e70b4f 100644 --- a/actionpack/test/template/date_helper_test.rb +++ b/actionpack/test/template/date_helper_test.rb @@ -1791,60 +1791,60 @@ class DateHelperTest < ActionView::TestCase def test_datetime_select_with_default_prompt @post = Post.new - @post.updated_at = Time.local(2004, 6, 15, 16, 35) + @post.updated_at = nil expected = %{\n" expected << %{\n" expected << %{\n" expected << " — " expected << %{\n" expected << " : " expected << %{\n" - assert_dom_equal expected, datetime_select("post", "updated_at", :prompt => true) + assert_dom_equal expected, datetime_select("post", "updated_at", :start_year=>1999, :end_year=>2009, :prompt => true) end def test_datetime_select_with_custom_prompt @post = Post.new - @post.updated_at = Time.local(2004, 6, 15, 16, 35) + @post.updated_at = nil expected = %{\n" expected << %{\n" expected << %{\n" expected << " — " expected << %{\n" expected << " : " expected << %{\n" - assert_dom_equal expected, datetime_select("post", "updated_at", :prompt => {:year => 'Choose year', :month => 'Choose month', :day => 'Choose day', :hour => 'Choose hour', :minute => 'Choose minute'}) + assert_dom_equal expected, datetime_select("post", "updated_at", :start_year=>1999, :end_year=>2009, :prompt => {:year => 'Choose year', :month => 'Choose month', :day => 'Choose day', :hour => 'Choose hour', :minute => 'Choose minute'}) end def test_date_select_with_zero_value_and_no_start_year -- 1.5.6.1