aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorVasiliy Ermolovich <younash@gmail.com>2011-12-24 00:44:23 +0300
committerVasiliy Ermolovich <younash@gmail.com>2011-12-24 00:44:23 +0300
commitf7669cd8344a83485d01f94e7b5896616cd57f51 (patch)
treeae8e12b164fc2354bd3de11dbf5cd71a7b147286 /actionpack/test
parent4d8ee28841261827c22322e769cb00c4f4fdc3e6 (diff)
downloadrails-f7669cd8344a83485d01f94e7b5896616cd57f51.tar.gz
rails-f7669cd8344a83485d01f94e7b5896616cd57f51.tar.bz2
rails-f7669cd8344a83485d01f94e7b5896616cd57f51.zip
add ability to set a prompt string in include_blank option for date helpers, closes #4143
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/template/date_helper_test.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/actionpack/test/template/date_helper_test.rb b/actionpack/test/template/date_helper_test.rb
index fadfb59572..21c9083386 100644
--- a/actionpack/test/template/date_helper_test.rb
+++ b/actionpack/test/template/date_helper_test.rb
@@ -1581,6 +1581,26 @@ class DateHelperTest < ActionView::TestCase
assert_dom_equal expected, date_select("post", "written_on", :include_blank => true)
end
+ def test_date_select_with_stringified_blank
+ @post = Post.new
+
+ start_year = Time.now.year-5
+ end_year = Time.now.year+5
+
+ expected = '<input name="post[written_on(3i)]" type="hidden" id="post_written_on_3i"/>' + "\n"
+ expected << %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n}
+ expected << "<option value=\"\">blank</option>\n"
+ start_year.upto(end_year) { |i| expected << %(<option value="#{i}">#{i}</option>\n) }
+ expected << "</select>\n"
+
+ expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n}
+ expected << "<option value=\"\">blank</option>\n"
+ 1.upto(12) { |i| expected << %(<option value="#{i}">#{Date::MONTHNAMES[i]}</option>\n) }
+ expected << "</select>\n"
+
+ assert_dom_equal expected, date_select("post", "written_on", :order=>[:year, :month], :include_blank=> 'blank')
+ end
+
def test_date_select_with_nil_and_blank_and_order
@post = Post.new