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

Remove virtual_path from fallback templates

This commit is contained in:
John Hawthorn 2019-03-18 11:57:05 -07:00
parent 98d0f93506
commit d0c745b863
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.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 @@ module ActionView
def self.instances
[new(""), new("/")]
end
def build_template(template, virtual_path, locals)
super(template, nil, locals)
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