Skip to content

Commit d189cbc

Browse files
committed
Revert "Merge pull request rails#51614 from gmcgibbon/defer_route_drawing"
This reverts commit e97db3b, reversing changes made to a27a175. This is breaking application routes when running without eager load enabled.
1 parent 272aa3b commit d189cbc

File tree

20 files changed

+11
-274
lines changed

20 files changed

+11
-274
lines changed

actionpack/lib/action_dispatch/testing/assertions/routing.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ def with_routing(&block)
4646
def create_routes
4747
app = self.app
4848
routes = ActionDispatch::Routing::RouteSet.new
49-
middleware = app.config.middleware.dup
50-
middleware.delete(Rails::Rack::LoadRoutes) if defined?(Rails::Rack::LoadRoutes)
51-
rack_app = middleware.build(routes)
49+
rack_app = app.config.middleware.build(routes)
5250
https = integration_session.https?
5351
host = integration_session.host
5452

actionpack/test/dispatch/routing_assertions_test.rb

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44
require "rails/engine"
55
require "controller/fake_controllers"
66

7-
class SecureArticlesController < ArticlesController
8-
def index
9-
render(inline: "")
10-
end
11-
end
7+
class SecureArticlesController < ArticlesController; end
128
class BlockArticlesController < ArticlesController; end
139
class QueryArticlesController < ArticlesController; end
1410

@@ -280,20 +276,6 @@ class RoutingAssertionsControllerTest < ActionController::TestCase
280276

281277
class WithRoutingTest < ActionController::TestCase
282278
include RoutingAssertionsSharedTests::WithRoutingSharedTests
283-
284-
test "with_routing routes are reachable" do
285-
@controller = SecureArticlesController.new
286-
287-
with_routing do |routes|
288-
routes.draw do
289-
get :new_route, to: "secure_articles#index"
290-
end
291-
292-
get :index
293-
294-
assert_predicate(response, :ok?)
295-
end
296-
end
297279
end
298280
end
299281

@@ -313,18 +295,6 @@ class RoutingAssertionsIntegrationTest < ActionDispatch::IntegrationTest
313295

314296
class WithRoutingTest < ActionDispatch::IntegrationTest
315297
include RoutingAssertionsSharedTests::WithRoutingSharedTests
316-
317-
test "with_routing routes are reachable" do
318-
with_routing do |routes|
319-
routes.draw do
320-
get :new_route, to: "secure_articles#index"
321-
end
322-
323-
get "/new_route"
324-
325-
assert_predicate(response, :ok?)
326-
end
327-
end
328298
end
329299

330300
class WithRoutingSettingsTest < ActionDispatch::IntegrationTest

railties/lib/rails/application.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
require "active_support/encrypted_configuration"
1010
require "active_support/hash_with_indifferent_access"
1111
require "active_support/configuration_file"
12-
require "active_support/parameter_filter"
1312
require "rails/engine"
1413
require "rails/autoloaders"
1514

railties/lib/rails/application/default_middleware_stack.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ def build_stack
6262
middleware.use ::ActionDispatch::ActionableExceptions
6363
end
6464

65-
middleware.use ::Rails::Rack::LoadRoutes, app.routes_reloader unless app.config.eager_load
66-
6765
if config.reloading_enabled?
6866
middleware.use ::ActionDispatch::Reloader, app.reloader
6967
end

railties/lib/rails/application/finisher.rb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ def self.complete(_state)
159159
initializer :set_routes_reloader_hook do |app|
160160
reloader = routes_reloader
161161
reloader.eager_load = app.config.eager_load
162+
reloader.execute
162163
reloaders << reloader
163164

164165
app.reloader.to_run do
@@ -176,12 +177,7 @@ def self.complete(_state)
176177
ActiveSupport.run_load_hooks(:after_routes_loaded, self)
177178
end
178179

179-
if reloader.eager_load
180-
reloader.execute
181-
ActiveSupport.run_load_hooks(:after_routes_loaded, self)
182-
elsif reloader.loaded
183-
ActiveSupport.run_load_hooks(:after_routes_loaded, self)
184-
end
180+
ActiveSupport.run_load_hooks(:after_routes_loaded, self)
185181
end
186182

187183
# Set clearing dependencies after the finisher hook to ensure paths

railties/lib/rails/application/routes_reloader.rb

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Application
77
class RoutesReloader
88
include ActiveSupport::Callbacks
99

10-
attr_reader :route_sets, :paths, :external_routes, :loaded
10+
attr_reader :route_sets, :paths, :external_routes
1111
attr_accessor :eager_load
1212
attr_writer :run_after_load_paths # :nodoc:
1313
delegate :execute_if_updated, :execute, :updated?, to: :updater
@@ -17,11 +17,9 @@ def initialize
1717
@route_sets = []
1818
@external_routes = []
1919
@eager_load = false
20-
@loaded = false
2120
end
2221

2322
def reload!
24-
@loaded = true
2523
clear!
2624
load_paths
2725
finalize!
@@ -30,13 +28,6 @@ def reload!
3028
revert
3129
end
3230

33-
def execute_unless_loaded
34-
unless @loaded
35-
execute
36-
true
37-
end
38-
end
39-
4031
private
4132
def updater
4233
@updater ||= begin

railties/lib/rails/commands/routes/routes_command.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ def invoke_command(*)
2323
desc "routes", "List all the defined routes"
2424
def perform(*)
2525
boot_application!
26-
Rails.application.routes_reloader.execute_unless_loaded
2726
require "action_dispatch/routing/inspector"
2827

2928
say inspector.format(formatter, routes_filter)

railties/lib/rails/commands/unused_routes/unused_routes_command.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ def action_missing?
4141

4242
def perform(*)
4343
boot_application!
44-
Rails.application.routes_reloader.execute_unless_loaded
4544
require "action_dispatch/routing/inspector"
4645

4746
say(inspector.format(formatter, routes_filter))

railties/lib/rails/engine.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,6 @@ module Rails
349349
# config.railties_order = [Blog::Engine, :main_app, :all]
350350
class Engine < Railtie
351351
autoload :Configuration, "rails/engine/configuration"
352-
autoload :RouteSet, "rails/engine/route_set"
353352

354353
class << self
355354
attr_accessor :called_from, :isolated
@@ -544,7 +543,7 @@ def env_config
544543
# Defines the routes for this engine. If a block is given to
545544
# routes, it is appended to the engine.
546545
def routes(&block)
547-
@routes ||= RouteSet.new_with_config(config)
546+
@routes ||= ActionDispatch::Routing::RouteSet.new_with_config(config)
548547
@routes.append(&block) if block_given?
549548
@routes
550549
end

railties/lib/rails/engine/route_set.rb

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

0 commit comments

Comments
 (0)