diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb index 5c8b09099c..8b6b2056a0 100644 --- a/actionpack/test/abstract_unit.rb +++ b/actionpack/test/abstract_unit.rb @@ -22,6 +22,7 @@ require "action_view/testing/resolvers" require "action_dispatch" require "active_support/dependencies" require "active_model" +require "zeitwerk" module Rails class << self @@ -159,16 +160,12 @@ class ActionDispatch::IntegrationTest < ActiveSupport::TestCase def with_autoload_path(path) path = File.join(__dir__, "fixtures", path) - if ActiveSupport::Dependencies.autoload_paths.include?(path) + Zeitwerk.with_loader do |loader| + loader.push_dir(path) + loader.setup yield - else - begin - ActiveSupport::Dependencies.autoload_paths << path - yield - ensure - ActiveSupport::Dependencies.autoload_paths.reject! { |p| p == path } - ActiveSupport::Dependencies.clear - end + ensure + loader.unload end end end diff --git a/actionpack/test/controller/live_stream_test.rb b/actionpack/test/controller/live_stream_test.rb index 2f7606255c..a9c7323655 100644 --- a/actionpack/test/controller/live_stream_test.rb +++ b/actionpack/test/controller/live_stream_test.rb @@ -3,6 +3,8 @@ require "abstract_unit" require "timeout" require "concurrent/atomic/count_down_latch" +require "zeitwerk" + Thread.abort_on_exception = true module ActionController @@ -173,18 +175,22 @@ module ActionController def write_sleep_autoload path = File.expand_path("../fixtures", __dir__) - ActiveSupport::Dependencies.autoload_paths << path + Zeitwerk.with_loader do |loader| + loader.push_dir(path) + loader.ignore(File.join(path, "公共")) + loader.setup - response.headers["Content-Type"] = "text/event-stream" - response.stream.write "before load" - sleep 0.01 - silence_warnings do - ::LoadMe + response.headers["Content-Type"] = "text/event-stream" + response.stream.write "before load" + sleep 0.01 + silence_warnings do + ::LoadMe + end + response.stream.close + latch.count_down + ensure + loader.unload end - response.stream.close - latch.count_down - - ActiveSupport::Dependencies.autoload_paths.reject! { |p| p == path } end def thread_locals diff --git a/actionpack/test/dispatch/session/cache_store_test.rb b/actionpack/test/dispatch/session/cache_store_test.rb index 205a1ae75d..9677d177d0 100644 --- a/actionpack/test/dispatch/session/cache_store_test.rb +++ b/actionpack/test/dispatch/session/cache_store_test.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require "abstract_unit" -require "fixtures/session_autoload_test/session_autoload_test/foo" class CacheStoreTest < ActionDispatch::IntegrationTest class TestController < ActionController::Base