Merge {Optimized,}FileSystemResolver

This commit is contained in:
John Hawthorn 2021-04-13 16:47:57 -07:00
parent e144f098f1
commit faac734387
5 changed files with 5 additions and 24 deletions

@ -72,7 +72,7 @@ def typecast(paths)
paths.map do |path|
case path
when Pathname, String
OptimizedFileSystemResolver.new path.to_s
FileSystemResolver.new path.to_s
else
path
end

@ -314,7 +314,7 @@ def extract_handler_and_format_and_variant(path)
end
# A resolver that loads files from the filesystem.
class FileSystemResolver < PathResolver
class FileSystemResolver < PathResolver #:nodoc:
attr_reader :path
def initialize(path)
@ -341,13 +341,6 @@ def all_template_paths # :nodoc:
filename.gsub(/\.[^\/]*\z/, "")
end.uniq
end
end
# An Optimized resolver for Rails' most common case.
class OptimizedFileSystemResolver < FileSystemResolver #:nodoc:
def initialize(path)
super(path)
end
private
def find_candidate_template_paths(path)

@ -7,7 +7,7 @@ module ActionView #:nodoc:
# file system. This is used internally by Rails' own test suite, and is
# useful for testing extensions that have no way of knowing what the file
# system will look like at runtime.
class FixtureResolver < OptimizedFileSystemResolver
class FixtureResolver < FileSystemResolver
def initialize(hash = {})
super("")
@hash = hash

@ -1,12 +0,0 @@
# frozen_string_literal: true
require "abstract_unit"
require "template/resolver_shared_tests"
class OptimizedFileSystemResolverTest < ActiveSupport::TestCase
include ResolverSharedTests
def resolver
ActionView::OptimizedFileSystemResolver.new(tmpdir)
end
end

@ -682,7 +682,7 @@ class CachedViewRenderTest < ActiveSupport::TestCase
def setup
ActionView::LookupContext::DetailsKey.clear
view_paths = ActionController::Base.view_paths
assert_equal ActionView::OptimizedFileSystemResolver, view_paths.first.class
assert_equal ActionView::FileSystemResolver, view_paths.first.class
setup_view(view_paths)
end
@ -756,7 +756,7 @@ class CachedCustomer < Customer; end
ActionView::LookupContext::DetailsKey.clear
view_paths = ActionController::Base.view_paths
assert_equal ActionView::OptimizedFileSystemResolver, view_paths.first.class
assert_equal ActionView::FileSystemResolver, view_paths.first.class
ActionView::PartialRenderer.collection_cache = ActiveSupport::Cache::MemoryStore.new