aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template
diff options
context:
space:
mode:
authorIndrek Juhkam <indrek@urgas.eu>2012-01-20 14:13:21 +0200
committerRafael Mendonça França <rafaelmfranca@gmail.com>2012-01-24 16:03:14 -0200
commitd4cfc4cec00b21f7fc47c094107168dbc0d8ed2c (patch)
tree2105de364e66b24805490a2a366a1828d2d3c25e /actionpack/test/template
parentdc826f9977650c105e9bfd308d6d4fc71bb6ec6e (diff)
downloadrails-d4cfc4cec00b21f7fc47c094107168dbc0d8ed2c.tar.gz
rails-d4cfc4cec00b21f7fc47c094107168dbc0d8ed2c.tar.bz2
rails-d4cfc4cec00b21f7fc47c094107168dbc0d8ed2c.zip
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.
Diffstat (limited to 'actionpack/test/template')
-rw-r--r--actionpack/test/template/date_helper_test.rb16
1 files changed, 16 insertions, 0 deletions
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 = "<input type=\"hidden\" id=\"post_written_on_3i\" name=\"post[written_on(3i)]\" value=\"1\" />\n"
+
+ expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n}
+ expected << %{<option value=""></option>\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n}
+ expected << "</select>\n"
+
+ expected << %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n}
+ expected << %{<option value=""></option>\n<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n}
+ expected << "</select>\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)