Skip to content

Commit

Permalink
Merge pull request rails#7410 from sandeepravi/default_options_helper…
Browse files Browse the repository at this point in the history
…_value

option_tags coerced to "" instead of nil

Closes rails#7404
  • Loading branch information
rafaelfranca committed Aug 21, 2012
1 parent 8905c1f commit c091fae
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions actionpack/CHANGELOG.md
@@ -1,5 +1,10 @@
## Rails 3.2.9 (unreleased) ##

* Fix select_tag when option_tags is nil.
Fixes #7404.

*Sandeep Ravichandran*

* `javascript_include_tag :all` will now not include `application.js` if the file does not exists. *Prem Sichanugrist*

* Support cookie jar options (e.g., domain :all) for all session stores.
Expand Down
1 change: 1 addition & 0 deletions actionpack/lib/action_view/helpers/form_tag_helper.rb
Expand Up @@ -119,6 +119,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)
Expand Down
12 changes: 12 additions & 0 deletions actionpack/test/template/form_tag_helper_test.rb
Expand Up @@ -220,6 +220,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>)
Expand Down

0 comments on commit c091fae

Please sign in to comment.