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

Merge pull request #35662 from jhawthorn/fallback_resolver_no_virtual_path

Remove virtual_path from fallback templates
This commit is contained in:
Aaron Patterson 2019-03-19 12:18:17 -07:00 committed by GitHub
commit 6f03c314de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 8 deletions

View file

@ -184,17 +184,21 @@ module ActionView
template_paths = reject_files_external_to_app(template_paths) unless outside_app_allowed template_paths = reject_files_external_to_app(template_paths) unless outside_app_allowed
template_paths.map do |template| template_paths.map do |template|
handler, format, variant = extract_handler_and_format_and_variant(template) build_template(template, path.virtual, locals)
FileTemplate.new(File.expand_path(template), handler,
virtual_path: path.virtual,
format: format,
variant: variant,
locals: locals
)
end end
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) def reject_files_external_to_app(files)
files.reject { |filename| !inside_path?(@path, filename) } files.reject { |filename| !inside_path?(@path, filename) }
end end
@ -385,5 +389,9 @@ module ActionView
def self.instances def self.instances
[new(""), new("/")] [new(""), new("/")]
end end
def build_template(template, virtual_path, locals)
super(template, nil, locals)
end
end end
end end

View file

@ -0,0 +1,16 @@
# 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