aboutsummaryrefslogtreecommitdiffstats
path: root/actionview
diff options
context:
space:
mode:
authorBogdan Gusiev <agresso@gmail.com>2014-08-05 17:23:00 +0300
committerBogdan Gusiev <agresso@gmail.com>2014-08-05 17:23:00 +0300
commit7a0c2ba48b0145e5031e51d316407ba28d769905 (patch)
tree5b578beaac65240990ff71ca88b01bbe76e37ac1 /actionview
parent3300fdedc748993b378288c6cbc3113885c955ed (diff)
downloadrails-7a0c2ba48b0145e5031e51d316407ba28d769905.tar.gz
rails-7a0c2ba48b0145e5031e51d316407ba28d769905.tar.bz2
rails-7a0c2ba48b0145e5031e51d316407ba28d769905.zip
Fixed #select form builder helper to support block with html output
Diffstat (limited to 'actionview')
-rw-r--r--actionview/lib/action_view/helpers/tags/select.rb2
-rw-r--r--actionview/test/template/form_options_helper_test.rb13
2 files changed, 14 insertions, 1 deletions
diff --git a/actionview/lib/action_view/helpers/tags/select.rb b/actionview/lib/action_view/helpers/tags/select.rb
index 00881d9978..180900cc8d 100644
--- a/actionview/lib/action_view/helpers/tags/select.rb
+++ b/actionview/lib/action_view/helpers/tags/select.rb
@@ -3,7 +3,7 @@ module ActionView
module Tags # :nodoc:
class Select < Base # :nodoc:
def initialize(object_name, method_name, template_object, choices, options, html_options)
- @choices = block_given? ? template_object.capture { yield } : choices
+ @choices = block_given? ? template_object.capture { yield || "" } : choices
@choices = @choices.to_a if @choices.is_a?(Range)
@html_options = html_options
diff --git a/actionview/test/template/form_options_helper_test.rb b/actionview/test/template/form_options_helper_test.rb
index fbafb7aa08..d25fa3706f 100644
--- a/actionview/test/template/form_options_helper_test.rb
+++ b/actionview/test/template/form_options_helper_test.rb
@@ -591,6 +591,19 @@ class FormOptionsHelperTest < ActionView::TestCase
)
end
+ def test_select_under_fields_for_with_block_without_options
+ @post = Post.new
+
+ output_buffer = fields_for :post, @post do |f|
+ concat(f.select(:category) {})
+ end
+
+ assert_dom_equal(
+ "<select id=\"post_category\" name=\"post[category]\"></select>",
+ output_buffer
+ )
+ end
+
def test_select_with_multiple_to_add_hidden_input
output_buffer = select(:post, :category, "", {}, :multiple => true)
assert_dom_equal(