aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Hawthorn <john@hawthorn.email>2019-03-18 11:57:05 -0700
committerJohn Hawthorn <john@hawthorn.email>2019-03-18 12:21:28 -0700
commitd0c745b8634be3bd830bc93998f199e18bebef49 (patch)
treeeaf7422b0dd95eb420153bcdee20228558919150
parent98d0f93506b0b97804d0d510ffcc435af9b2a2d5 (diff)
downloadrails-d0c745b8634be3bd830bc93998f199e18bebef49.tar.gz
rails-d0c745b8634be3bd830bc93998f199e18bebef49.tar.bz2
rails-d0c745b8634be3bd830bc93998f199e18bebef49.zip
Remove virtual_path from fallback templates
-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