From d4cfc4cec00b21f7fc47c094107168dbc0d8ed2c Mon Sep 17 00:00:00 2001 From: Indrek Juhkam Date: Fri, 20 Jan 2012 14:13:21 +0200 Subject: Add failing test for date_select date_select does not work when day is discarded, include blank option is enabled and struct date itself is nil. --- actionpack/test/template/date_helper_test.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'actionpack/test') diff --git a/actionpack/test/template/date_helper_test.rb b/actionpack/test/template/date_helper_test.rb index fadfb59572..43fece397b 100644 --- a/actionpack/test/template/date_helper_test.rb +++ b/actionpack/test/template/date_helper_test.rb @@ -1396,6 +1396,22 @@ class DateHelperTest < ActionView::TestCase assert_dom_equal expected, date_select("post", "written_on", :order => [ :month, :year ]) end + def test_date_select_without_day_and_include_blank_option_when_written_on_is_nil + @post = Post.new + + expected = "\n" + + expected << %{\n" + + expected << %{\n" + + assert_dom_equal expected, date_select("post", "written_on", :start_year => 1999, :end_year => 2009, :order => [ :month, :year ], :discard_day => true, :include_blank => true) + end + def test_date_select_without_day_with_separator @post = Post.new @post.written_on = Date.new(2004, 6, 15) -- cgit v1.2.3 From d92b5fe07cc178f14bdd5a4ecf4adb8b96dcdd7e Mon Sep 17 00:00:00 2001 From: Indrek Juhkam Date: Fri, 20 Jan 2012 18:42:04 +0200 Subject: Fix date_select nil and blank and order case --- actionpack/test/template/date_helper_test.rb | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'actionpack/test') diff --git a/actionpack/test/template/date_helper_test.rb b/actionpack/test/template/date_helper_test.rb index 43fece397b..3614d2e77d 100644 --- a/actionpack/test/template/date_helper_test.rb +++ b/actionpack/test/template/date_helper_test.rb @@ -1396,22 +1396,6 @@ class DateHelperTest < ActionView::TestCase assert_dom_equal expected, date_select("post", "written_on", :order => [ :month, :year ]) end - def test_date_select_without_day_and_include_blank_option_when_written_on_is_nil - @post = Post.new - - expected = "\n" - - expected << %{\n" - - expected << %{\n" - - assert_dom_equal expected, date_select("post", "written_on", :start_year => 1999, :end_year => 2009, :order => [ :month, :year ], :discard_day => true, :include_blank => true) - end - def test_date_select_without_day_with_separator @post = Post.new @post.written_on = Date.new(2004, 6, 15) @@ -1603,7 +1587,7 @@ class DateHelperTest < ActionView::TestCase start_year = Time.now.year-5 end_year = Time.now.year+5 - expected = '' + "\n" + expected = '' + "\n" expected << %{\n} + expected << "\n" + start_year.upto(end_year) { |i| expected << %(\n) } + expected << "\n" + expected << '' + "\n" + expected << '' + "\n" + + assert_dom_equal expected, date_select("post", "written_on", :discard_month => true, :include_blank=>true) + end + + def test_date_select_with_nil_and_blank_and_discard_year + @post = Post.new + + start_year = Time.now.year-5 + end_year = Time.now.year+5 + + expected = '' + "\n" + + expected << %{\n" + + expected << %{\n" + + assert_dom_equal expected, date_select("post", "written_on", :discard_year => true, :include_blank=>true) + end + def test_date_select_cant_override_discard_hour @post = Post.new @post.written_on = Date.new(2004, 6, 15) -- cgit v1.2.3