mirror of https://github.com/rails/rails
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:
commit
03173c4108
|
@ -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};" }
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue