-
Jonathan Hefner authored
In the case where a controller subclasses an engine's controller that, in turn, subclasses a controller that includes the application's `url_helpers` (for example, in the "isolated engine routes and helpers are isolated to that engine" test in `railties/test/railties/engine_test.rb`), this commit avoids allocating a new module per controller: ```ruby ActionController::Base.include Rails.application.routes.url_helpers C1 = Class.new(ActiveStorage::DirectUploadsController) C2 = Class.new(ActiveStorage::DirectUploadsController) C1.ancestors - C2.ancestors # BEFORE: # => [C1, #<Module:0x...>] # AFTER: # => [C1] ``` This commit also modifies the `RouteHelperIntegrationTest` test to use the controllers defined in `actionpack/test/abstract_unit.rb`. Otherwise, `extend AbstractController::Railties::RoutesHelpers.with(...)` happens twice -- once for `ActionController::Base` and once for `FakeACBase` -- which causes `FooController` to include an extra module as it flip-flops its `_routes` definition. Previously, the extra module only defined a `_routes` method; now, the extra module would be the memoized dup of `routes.url_helpers`, which would cause the "only includes one module with route helpers" test to falsely fail.
Jonathan Hefner authoredIn the case where a controller subclasses an engine's controller that, in turn, subclasses a controller that includes the application's `url_helpers` (for example, in the "isolated engine routes and helpers are isolated to that engine" test in `railties/test/railties/engine_test.rb`), this commit avoids allocating a new module per controller: ```ruby ActionController::Base.include Rails.application.routes.url_helpers C1 = Class.new(ActiveStorage::DirectUploadsController) C2 = Class.new(ActiveStorage::DirectUploadsController) C1.ancestors - C2.ancestors # BEFORE: # => [C1, #<Module:0x...>] # AFTER: # => [C1] ``` This commit also modifies the `RouteHelperIntegrationTest` test to use the controllers defined in `actionpack/test/abstract_unit.rb`. Otherwise, `extend AbstractController::Railties::RoutesHelpers.with(...)` happens twice -- once for `ActionController::Base` and once for `FakeACBase` -- which causes `FooController` to include an extra module as it flip-flops its `_routes` definition. Previously, the extra module only defined a `_routes` method; now, the extra module would be the memoized dup of `routes.url_helpers`, which would cause the "only includes one module with route helpers" test to falsely fail.
Loading