From db6179d12f06895aa3d813c495ff77bbddf439d1 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 15 Dec 2004 12:47:50 +0000 Subject: Fixed DateHelper#date_select so that you can pass include_blank as an option even if you don't use start_year and end_year #59 [what-a-day] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@167 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/test/template/date_helper_test.rb | 144 +++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/date_helper_test.rb b/actionpack/test/template/date_helper_test.rb index 5e9d79b26e..30cb73da71 100755 --- a/actionpack/test/template/date_helper_test.rb +++ b/actionpack/test/template/date_helper_test.rb @@ -101,4 +101,148 @@ class DateHelperTest < Test::Unit::TestCase Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005, :prefix => "date[first]" ) end + + def test_select_date_with_no_start_year + expected = %(\n" + + expected << %(\n" + + expected << %(\n" + + assert_equal expected, select_date( + Time.mktime(Date.today.year, 8, 16), :end_year => Date.today.year+1, :prefix => "date[first]" + ) + end + + def test_select_date_with_no_end_year + expected = %(\n" + + expected << %(\n" + + expected << %(\n" + + assert_equal expected, select_date( + Time.mktime(2003, 8, 16), :start_year => 2003, :prefix => "date[first]" + ) + end + + def test_select_date_with_no_start_or_end_year + expected = %(\n" + + expected << %(\n" + + expected << %(\n" + + assert_equal expected, select_date( + Time.mktime(Date.today.year, 8, 16), :prefix => "date[first]" + ) + end + + def test_date_select_with_zero_value + expected = %(\n" + + expected << %(\n" + + expected << %(\n" + + assert_equal expected, select_date(0, :start_year => 2003, :end_year => 2005, :prefix => "date[first]") + end + + def test_date_select_with_zero_value_and_no_start_year + expected = %(\n" + + expected << %(\n" + + expected << %(\n" + + assert_equal expected, select_date(0, :end_year => Date.today.year+1, :prefix => "date[first]") + end + + def test_date_select_with_zero_value_and_no_end_year + expected = %(\n" + + expected << %(\n" + + expected << %(\n" + + assert_equal expected, select_date(0, :start_year => 2003, :prefix => "date[first]") + end + + def test_date_select_with_zero_value_and_no_start_and_end_year + expected = %(\n" + + expected << %(\n" + + expected << %(\n" + + assert_equal expected, select_date(0, :prefix => "date[first]") + end + end -- cgit v1.2.3