Merge pull request #41468 from p8/update-depraction-warnings-to-7.1

Update Rails version in deprecation and add non-deprecated code
This commit is contained in:
Rafael França 2021-02-17 09:03:51 -05:00 committed by GitHub
commit 03173c4108
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -323,10 +323,12 @@ module ActionView
if deprecated_locals.any?
ActiveSupport::Deprecation.warn(<<~MSG)
Passing instance variables to `render` is deprecated.
In Rails 7.0, #{deprecated_locals.to_sentence} will be ignored.
In Rails 7.1, #{deprecated_locals.to_sentence} will be ignored.
MSG
locals = locals.grep(/\A@?(?![A-Z0-9])(?:[[:alnum:]_]|[^\0-\177])+\z/)
else
locals = locals.grep(/\A(?![A-Z0-9])(?:[[:alnum:]_]|[^\0-\177])+\z/)
end
locals = locals.grep(/\A@?(?![A-Z0-9])(?:[[:alnum:]_]|[^\0-\177])+\z/)
# Assign for the same variable is to suppress unused variable warning
locals.each_with_object(+"") { |key, code| code << "#{key} = local_assigns[:#{key}]; #{key} = #{key};" }

View File

@ -52,7 +52,7 @@ class CompiledTemplatesTest < ActiveSupport::TestCase
end
def test_template_with_instance_variable_identifier
expected_deprecation = "In Rails 7.0, @foo will be ignored."
expected_deprecation = "In Rails 7.1, @foo will be ignored."
assert_deprecated(expected_deprecation) do
assert_equal "bar", render(template: "test/render_file_instance_variable", locals: { "@foo": "bar" })
end