From d6d94c7377b60aac92f3718cafc4b3e6c3852fe3 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sun, 28 Jan 2007 16:44:44 +0000 Subject: date_select and datetime_select take a :default option. Closes #7052. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6080 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/test/template/date_helper_test.rb | 74 ++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) (limited to 'actionpack/test') diff --git a/actionpack/test/template/date_helper_test.rb b/actionpack/test/template/date_helper_test.rb index 07b0fa9c09..340175b9c9 100755 --- a/actionpack/test/template/date_helper_test.rb +++ b/actionpack/test/template/date_helper_test.rb @@ -1318,4 +1318,78 @@ class DateHelperTest < Test::Unit::TestCase assert_equal expected, datetime_select("post", "updated_at", :order => [:day, :month]) end + + def test_datetime_select_with_default_value_as_time + @post = Post.new + @post.updated_at = nil + + expected = %{\n" + expected << %{\n" + expected << %{\n" + + expected << " — " + + expected << %{\n" + expected << " : " + expected << %{\n" + + assert_equal expected, datetime_select("post", "updated_at", :default => Time.local(2006, 9, 19, 15, 16, 35)) + end + + def test_include_blank_overrides_default_option + @post = Post.new + @post.updated_at = nil + + expected = %{\n" + expected << %{\n" + expected << %{\n" + + assert_equal expected, date_select("post", "updated_at", :default => Time.local(2006, 9, 19, 15, 16, 35), :include_blank => true) + end + + def test_datetime_select_with_default_value_as_hash + @post = Post.new + @post.updated_at = nil + + expected = %{\n" + expected << %{\n" + expected << %{\n" + + expected << " — " + + expected << %{\n" + expected << " : " + expected << %{\n" + + assert_equal expected, datetime_select("post", "updated_at", :default => { :month => 10, :minute => 42, :hour => 9 }) + end end -- cgit v1.2.3