Skip to content

Commit a9c0002

Browse files
authored
Merge pull request rails#41846 from jhawthorn/remove_template_fallbacks
Remove FallbackFileSystemResolver
2 parents bc48843 + fb6b0a5 commit a9c0002

File tree

7 files changed

+0
-71
lines changed

7 files changed

+0
-71
lines changed

actionview/lib/action_view/lookup_context.rb

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ module ActionView
1515
class LookupContext #:nodoc:
1616
attr_accessor :prefixes, :rendered_format
1717

18-
mattr_accessor :fallbacks, default: FallbackFileSystemResolver.instances
19-
2018
mattr_accessor :registered_details, default: []
2119

2220
def self.register_detail(name, &block)
@@ -75,7 +73,6 @@ def self.clear
7573
ActionView::ViewPaths.all_view_paths.each do |path_set|
7674
path_set.each(&:clear_cache)
7775
end
78-
ActionView::LookupContext.fallbacks.each(&:clear_cache)
7976
@view_context_class = nil
8077
@details_keys.clear
8178
@digest_cache.clear
@@ -142,21 +139,6 @@ def any?(name, prefixes = [], partial = false)
142139
end
143140
alias :any_templates? :any?
144141

145-
# Adds fallbacks to the view paths. Useful in cases when you are rendering
146-
# a :file.
147-
def with_fallbacks
148-
view_paths = build_view_paths((@view_paths.paths + self.class.fallbacks).uniq)
149-
150-
if block_given?
151-
raise ArgumentError, <<~eowarn.squish
152-
Calling `with_fallbacks` with a block is not supported. Call methods on
153-
the lookup context returned by `with_fallbacks` instead.
154-
eowarn
155-
else
156-
ActionView::LookupContext.new(view_paths, @details, @prefixes)
157-
end
158-
end
159-
160142
private
161143
# Whenever setting view paths, makes a copy so that we can manipulate them in
162144
# instance objects as we wish.

actionview/lib/action_view/template/resolver.rb

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -411,22 +411,4 @@ def build_regex(path, details)
411411
%r{\A#{query}#{exts}\z}
412412
end
413413
end
414-
415-
# The same as FileSystemResolver but does not allow templates to store
416-
# a virtual path since it is invalid for such resolvers.
417-
class FallbackFileSystemResolver < FileSystemResolver #:nodoc:
418-
private_class_method :new
419-
420-
def self.instances
421-
[new(""), new("/")]
422-
end
423-
424-
def build_unbound_template(template, _)
425-
super(template, nil)
426-
end
427-
428-
def reject_files_external_to_app(files)
429-
files
430-
end
431-
end
432414
end

actionview/test/activerecord/multifetch_cache_test.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ class MultifetchCacheTest < ActiveRecordTestCase
88
def setup
99
view_paths = ActionController::Base.view_paths
1010
view_paths.each(&:clear_cache)
11-
ActionView::LookupContext.fallbacks.each(&:clear_cache)
1211

1312
@view = Class.new(ActionView::Base.with_empty_template_cache) do
1413
def view_cache_dependencies

actionview/test/template/compiled_templates_test.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ def setup
99
super
1010
view_paths = ActionController::Base.view_paths
1111
view_paths.each(&:clear_cache)
12-
ActionView::LookupContext.fallbacks.each(&:clear_cache)
1312
@view_class = ActionView::Base.with_empty_template_cache
1413
end
1514

actionview/test/template/fallback_file_system_resolver_test.rb

Lines changed: 0 additions & 16 deletions
This file was deleted.

actionview/test/template/lookup_context_test.rb

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -127,22 +127,6 @@ def teardown
127127
end
128128
end
129129

130-
test "adds fallbacks to view paths when required" do
131-
assert_equal 1, @lookup_context.view_paths.size
132-
133-
@lookup_context = @lookup_context.with_fallbacks
134-
135-
assert_equal 3, @lookup_context.view_paths.size
136-
assert_includes @lookup_context.view_paths, ActionView::FallbackFileSystemResolver.instances[0]
137-
assert_includes @lookup_context.view_paths, ActionView::FallbackFileSystemResolver.instances[1]
138-
end
139-
140-
test "with_fallbacks with block raises an ArgumentError" do
141-
assert_raises(ArgumentError) do
142-
@lookup_context.with_fallbacks { }
143-
end
144-
end
145-
146130
test "generates a new details key for each details hash" do
147131
keys = []
148132
keys << @lookup_context.details_key

actionview/test/template/translation_helper_test.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ class TranslationHelperTest < ActiveSupport::TestCase
4141
)
4242
view_paths = ActionController::Base.view_paths
4343
view_paths.each(&:clear_cache)
44-
ActionView::LookupContext.fallbacks.each(&:clear_cache)
4544
@view = ::ActionView::Base.with_empty_template_cache.with_view_paths(view_paths, {})
4645
end
4746

0 commit comments

Comments
 (0)