From f04346d8b999476113d5e5a30661e07899e3ff80 Mon Sep 17 00:00:00 2001 From: Sam Oliver Date: Fri, 2 Jan 2009 15:34:38 +0000 Subject: Stops date select helpers from defaulting the selected date to today if :prompt option has been used Signed-off-by: Michael Koziarski [#561 state:resolved] --- 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 b4c1adbe76..b7ef1fb90d 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 59e921f09b..2e4763f446 100644 --- a/actionpack/test/template/date_helper_test.rb +++ b/actionpack/test/template/date_helper_test.rb @@ -1820,60 +1820,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 -- cgit v1.2.3