aboutsummaryrefslogtreecommitdiffstats
path: root/actionview
diff options
context:
space:
mode:
authorAaron Patterson <tenderlove@github.com>2019-03-19 12:18:17 -0700
committerGitHub <noreply@github.com>2019-03-19 12:18:17 -0700
commit6f03c314de8a24b31536832e9acb6bf8ffda9b82 (patch)
treea2f466f67878d80f706d6b970a557d39956d4032 /actionview
parent7180fa7ba8ee8444de57bfcbc284c17e9bc1330f (diff)
parentd0c745b8634be3bd830bc93998f199e18bebef49 (diff)
downloadrails-6f03c314de8a24b31536832e9acb6bf8ffda9b82.tar.gz
rails-6f03c314de8a24b31536832e9acb6bf8ffda9b82.tar.bz2
rails-6f03c314de8a24b31536832e9acb6bf8ffda9b82.zip
Merge pull request #35662 from jhawthorn/fallback_resolver_no_virtual_path
Remove virtual_path from fallback templates
Diffstat (limited to 'actionview')
-rw-r--r--actionview/lib/action_view/template/resolver.rb24
-rw-r--r--actionview/test/template/fallback_file_system_resolver_test.rb16
2 files changed, 32 insertions, 8 deletions
diff --git a/actionview/lib/action_view/template/resolver.rb b/actionview/lib/action_view/template/resolver.rb
index 07c44307ff..1c577348e5 100644
--- a/actionview/lib/action_view/template/resolver.rb
+++ b/actionview/lib/action_view/template/resolver.rb
@@ -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
diff --git a/actionview/test/template/fallback_file_system_resolver_test.rb b/actionview/test/template/fallback_file_system_resolver_test.rb
new file mode 100644
index 0000000000..304cdb8a03
--- /dev/null
+++ b/actionview/test/template/fallback_file_system_resolver_test.rb
@@ -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