diff options
author | Lecky Lao <leckylao@au1.ibm.com> | 2014-07-22 16:03:55 +1000 |
---|---|---|
committer | Sean Griffin <sean@seantheprogrammer.com> | 2015-10-29 11:02:31 -0600 |
commit | 462698b2c704eff962060ed5851af80f4215958b (patch) | |
tree | e0d0b1274ce5386a046fb5b94f95d08093534996 /actionview/test/template | |
parent | 857a34a41622300457c0a52885d53344a3e36505 (diff) | |
download | rails-462698b2c704eff962060ed5851af80f4215958b.tar.gz rails-462698b2c704eff962060ed5851af80f4215958b.tar.bz2 rails-462698b2c704eff962060ed5851af80f4215958b.zip |
making selected value to accept Hash like the default option. E.g. selected: {day: params[:day].to_i, month: params[:month].to_id}
Adds in test test_date_select_with_selected_in_hash and change log
fixes typo in CHANGELOG
Diffstat (limited to 'actionview/test/template')
-rw-r--r-- | actionview/test/template/date_helper_test.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/actionview/test/template/date_helper_test.rb b/actionview/test/template/date_helper_test.rb index 9212420ec9..c4234a71c3 100644 --- a/actionview/test/template/date_helper_test.rb +++ b/actionview/test/template/date_helper_test.rb @@ -1559,6 +1559,26 @@ class DateHelperTest < ActionView::TestCase assert_dom_equal expected, date_select("post", "written_on", :selected => Date.new(2004, 07, 10)) end + def test_date_select_with_selected_in_hash + @post = Post.new + @post.written_on = Date.new(2004, 6, 15) + + expected = %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n} + expected << %{<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 selected="selected" 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" + + expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n} + expected << %{<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" selected="selected">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_3i" name="post[written_on(3i)]">\n} + expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10" selected="selected">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n} + + expected << "</select>\n" + + assert_dom_equal expected, date_select("post", "written_on", :selected => {day: 10, month: 07, year: 2004}) + end + def test_date_select_with_selected_nil @post = Post.new @post.written_on = Date.new(2004, 6, 15) |