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:
commit
92d3afe475
2 changed files with 19 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue