aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2012-08-25 09:04:33 -0700
committerRafael Mendonça França <rafaelmfranca@gmail.com>2012-08-25 09:04:33 -0700
commit67153430861ca1305d77a73e631a9038049fbfa9 (patch)
treef3cc50274fca7d62002ad0852527cc6f122266be /actionpack/test
parentdfb5898b6dd448a6867dcd26ebcbe0835b26a1e2 (diff)
parent130fe2b172afb81979e72fbf30edf945147cb78f (diff)
downloadrails-67153430861ca1305d77a73e631a9038049fbfa9.tar.gz
rails-67153430861ca1305d77a73e631a9038049fbfa9.tar.bz2
rails-67153430861ca1305d77a73e631a9038049fbfa9.zip
Merge pull request #7435 from nashby/fix-issue-7431
correct handling of date selects when using both disabled and discard options
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/template/date_helper_test.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/actionpack/test/template/date_helper_test.rb b/actionpack/test/template/date_helper_test.rb
index c13878af98..a4da7cd4b0 100644
--- a/actionpack/test/template/date_helper_test.rb
+++ b/actionpack/test/template/date_helper_test.rb
@@ -2658,6 +2658,30 @@ class DateHelperTest < ActionView::TestCase
assert_dom_equal expected, datetime_select("post", "updated_at", :discard_minute => true)
end
+ def test_datetime_select_disabled_and_discard_minute
+ @post = Post.new
+ @post.updated_at = Time.local(2004, 6, 15, 15, 16, 35)
+
+ expected = %{<select id="post_updated_at_1i" disabled="disabled" name="post[updated_at(1i)]">\n}
+ 1999.upto(2009) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 2004}>#{i}</option>\n) }
+ expected << "</select>\n"
+ expected << %{<select id="post_updated_at_2i" disabled="disabled" name="post[updated_at(2i)]">\n}
+ 1.upto(12) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 6}>#{Date::MONTHNAMES[i]}</option>\n) }
+ expected << "</select>\n"
+ expected << %{<select id="post_updated_at_3i" disabled="disabled" name="post[updated_at(3i)]">\n}
+ 1.upto(31) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 15}>#{i}</option>\n) }
+ expected << "</select>\n"
+
+ expected << " &mdash; "
+
+ expected << %{<select id="post_updated_at_4i" disabled="disabled" name="post[updated_at(4i)]">\n}
+ 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) }
+ expected << "</select>\n"
+ expected << %{<input type="hidden" id="post_updated_at_5i" disabled="disabled" name="post[updated_at(5i)]" value="16" />\n}
+
+ assert_dom_equal expected, datetime_select("post", "updated_at", :discard_minute => true, :disabled => true)
+ end
+
def test_datetime_select_invalid_order
@post = Post.new
@post.updated_at = Time.local(2004, 6, 15, 15, 16, 35)