mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #30647 from droptheplot/render-partials-string-locals
Allow usage of strings as locals for partial renderer
This commit is contained in:
commit
ce58a64f19
2 changed files with 10 additions and 1 deletions
|
@ -363,7 +363,7 @@ module ActionView
|
|||
@options = options
|
||||
@block = block
|
||||
|
||||
@locals = options[:locals] || {}
|
||||
@locals = options[:locals] ? options[:locals].symbolize_keys : {}
|
||||
@details = extract_details(options)
|
||||
|
||||
prepend_formats(options[:formats])
|
||||
|
|
|
@ -485,6 +485,10 @@ class TestController < ActionController::Base
|
|||
render partial: "customer", locals: { customer: Customer.new("david") }
|
||||
end
|
||||
|
||||
def partial_with_string_locals
|
||||
render partial: "customer", locals: { "customer" => Customer.new("david") }
|
||||
end
|
||||
|
||||
def partial_with_form_builder
|
||||
render partial: ActionView::Helpers::FormBuilder.new(:post, nil, view_context, {})
|
||||
end
|
||||
|
@ -1170,6 +1174,11 @@ class RenderTest < ActionController::TestCase
|
|||
assert_equal "Hello: david", @response.body
|
||||
end
|
||||
|
||||
def test_partial_with_string_locals
|
||||
get :partial_with_string_locals
|
||||
assert_equal "Hello: david", @response.body
|
||||
end
|
||||
|
||||
def test_partial_with_form_builder
|
||||
get :partial_with_form_builder
|
||||
assert_equal "<label for=\"post_title\">Title</label>\n", @response.body
|
||||
|
|
Loading…
Reference in a new issue