未验证 提交 6f03c314 编写于 作者: A Aaron Patterson 提交者: GitHub

Merge pull request #35662 from jhawthorn/fallback_resolver_no_virtual_path

Remove virtual_path from fallback templates
......@@ -184,17 +184,21 @@ def query(path, details, formats, outside_app_allowed, locals)
template_paths = reject_files_external_to_app(template_paths) unless outside_app_allowed
template_paths.map do |template|
handler, format, variant = extract_handler_and_format_and_variant(template)
FileTemplate.new(File.expand_path(template), handler,
virtual_path: path.virtual,
format: format,
variant: variant,
locals: locals
)
build_template(template, path.virtual, locals)
end
end
def build_template(template, virtual_path, locals)
handler, format, variant = extract_handler_and_format_and_variant(template)
FileTemplate.new(File.expand_path(template), handler,
virtual_path: virtual_path,
format: format,
variant: variant,
locals: locals
)
end
def reject_files_external_to_app(files)
files.reject { |filename| !inside_path?(@path, filename) }
end
......@@ -385,5 +389,9 @@ class FallbackFileSystemResolver < FileSystemResolver #:nodoc:
def self.instances
[new(""), new("/")]
end
def build_template(template, virtual_path, locals)
super(template, nil, locals)
end
end
end
# frozen_string_literal: true
require "abstract_unit"
class FallbackFileSystemResolverTest < ActiveSupport::TestCase
def setup
@root_resolver = ActionView::FallbackFileSystemResolver.new("/")
end
def test_should_have_no_virtual_path
templates = @root_resolver.find_all("hello_world.erb", "#{FIXTURE_LOAD_PATH}/test", false, locale: [], formats: [:html], variants: [], handlers: [:erb])
assert_equal 1, templates.size
assert_equal "Hello world!", templates[0].source
assert_nil templates[0].virtual_path
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册