aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test
diff options
context:
space:
mode:
authorGrey Baker <greysteil@gmail.com>2015-05-12 15:10:20 +0100
committerGrey Baker <greysteil@gmail.com>2015-06-08 16:41:44 +0100
commit077540738460d44c1463b3e52d2acb1fed9bc766 (patch)
tree7372acefce4ae672f204c07f6282bd2916724aa0 /actionview/test
parentaeac00feb41ec99ef39b79cae31546ca875188d9 (diff)
downloadrails-077540738460d44c1463b3e52d2acb1fed9bc766.tar.gz
rails-077540738460d44c1463b3e52d2acb1fed9bc766.tar.bz2
rails-077540738460d44c1463b3e52d2acb1fed9bc766.zip
Raise an ArgumentError when `include_blank` is false for a required field in
`Tags::Base#select_content_tag`. Previously, passing a falsey value to `include_blank` would be ignored if the field was required, and a blank line would still be inserted. The following will now raise instead of quietly failing: `select("post", "category", %w(a required field), { include_blank: false }, required: 'required')`
Diffstat (limited to 'actionview/test')
-rw-r--r--actionview/test/template/form_options_helper_test.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/actionview/test/template/form_options_helper_test.rb b/actionview/test/template/form_options_helper_test.rb
index d25fa3706f..d7daba8bf3 100644
--- a/actionview/test/template/form_options_helper_test.rb
+++ b/actionview/test/template/form_options_helper_test.rb
@@ -645,6 +645,13 @@ class FormOptionsHelperTest < ActionView::TestCase
)
end
+ def test_select_with_include_blank_false_and_required
+ @post = Post.new
+ @post.category = "<mus>"
+ e = assert_raises(ArgumentError) { select("post", "category", %w( abe <mus> hest), { include_blank: false }, required: 'required') }
+ assert_match(/include_blank cannot be false for a required field./, e.message)
+ end
+
def test_select_with_blank_as_string
@post = Post.new
@post.category = "<mus>"