1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #39068 from jhawthorn/dependency_tracker_interpolation

Ignore interpolated strings in DependencyTracker
This commit is contained in:
John Hawthorn 2020-05-05 23:21:00 -07:00 committed by GitHub
commit 92d3afe475
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 3 deletions

View file

@ -130,8 +130,9 @@ module ActionView
def add_dependencies(render_dependencies, arguments, pattern)
arguments.scan(pattern) do
add_dynamic_dependency(render_dependencies, Regexp.last_match[:dynamic])
add_static_dependency(render_dependencies, Regexp.last_match[:static])
match = Regexp.last_match
add_dynamic_dependency(render_dependencies, match[:dynamic])
add_static_dependency(render_dependencies, match[:static], match[:quote])
end
end
@ -141,7 +142,12 @@ module ActionView
end
end
def add_static_dependency(dependencies, dependency)
def add_static_dependency(dependencies, dependency, quote_type)
if quote_type == '"'
# Ignore if there is interpolation
return if dependency.include?('#{')
end
if dependency
if dependency.include?("/")
dependencies << dependency

View file

@ -192,4 +192,14 @@ class ERBTrackerTest < Minitest::Test
"comments/comment"
], tracker.dependencies
end
def test_dependencies_with_interpolation
template = FakeTemplate.new(%q{
<%# render "double/#{quote}" %>
<%# render 'single/#{quote}' %>
}, :erb)
tracker = make_tracker("interpolation/_string", template)
assert_equal ["single/\#{quote}"], tracker.dependencies
end
end