1
0
Fork 0
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:
Rafael França 2018-04-27 19:17:36 -04:00 committed by GitHub
commit ce58a64f19
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View file

@ -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])

View file

@ -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