From 077540738460d44c1463b3e52d2acb1fed9bc766 Mon Sep 17 00:00:00 2001 From: Grey Baker Date: Tue, 12 May 2015 15:10:20 +0100 Subject: 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')` --- actionview/test/template/form_options_helper_test.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'actionview/test') 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 = "" + e = assert_raises(ArgumentError) { select("post", "category", %w( abe 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 = "" -- cgit v1.2.3