1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionview/test/template/fallback_file_system_resolver_test.rb
John Hawthorn dd9991bac5 Deprecate rendering templates with . in the name
Allowing templates with "." introduces some ambiguity. Is index.html.erb
a template named "index" with format "html", or is it a template named
"index.html" without a format? We know it's probably the former, but if
we asked ActionView to render "index.html" we would currently get some
combination of the two: a Template with index.html as the name and
virtual path, but with html as the format.

This deprecates having "." anywhere in the template's name, we should
reserve this character for specifying formats. I think in 99% of cases
this will be people specifying `index.html` instead of simply `index`.

This was actually once deprecated in the 3.x series (removed in
6c57177f2c) but I don't think we can rely
on nobody having introduced this in the past 8 years.
2020-05-05 23:21:17 -07:00

16 lines
545 B
Ruby

# frozen_string_literal: true
require "abstract_unit"
class FallbackFileSystemResolverTest < ActiveSupport::TestCase
def setup
@root_resolver = ActionView::FallbackFileSystemResolver.send(:new, "/")
end
def test_should_have_no_virtual_path
templates = @root_resolver.find_all("hello_world", "#{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