Permalink
Browse files

Merge pull request #7410 from sandeepravi/default_options_helper_value

option_tags coerced to "" instead of nil

Closes #7404
  • Loading branch information...
rafaelfranca committed Aug 21, 2012
2 parents 5c4fe85 + 9932226 commit ce0dd56183d198739638c2cfa7c17f90513a7072
@@ -118,6 +118,7 @@ def form_tag(url_for_options = {}, options = {}, &block)
# # => <select disabled="disabled" id="destination" name="destination"><option>NYC</option>
# # <option>Paris</option><option>Rome</option></select>
def select_tag(name, option_tags = nil, options = {})
+ option_tags ||= ""
html_name = (options[:multiple] == true && !name.to_s.ends_with?("[]")) ? "#{name}[]" : name
if options.delete(:include_blank)
@@ -225,6 +225,18 @@ def test_select_tag_with_prompt_and_include_blank
assert_dom_equal expected, actual
end
+ def test_select_tag_with_nil_option_tags_and_include_blank
+ actual = select_tag "places", nil, :include_blank => true
+ expected = %(<select id="places" name="places"><option value=""></option></select>)
+ assert_dom_equal expected, actual
+ end
+
+ def test_select_tag_with_nil_option_tags_and_prompt
+ actual = select_tag "places", nil, :prompt => "string"
+ expected = %(<select id="places" name="places"><option value="">string</option></select>)
+ assert_dom_equal expected, actual
+ end
+
def test_text_area_tag_size_string
actual = text_area_tag "body", "hello world", "size" => "20x40"
expected = %(<textarea cols="20" id="body" name="body" rows="40">\nhello world</textarea>)

0 comments on commit ce0dd56

Please sign in to comment.