Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix Engine#routes to not call draw_paths multiple times

  • Loading branch information...
commit 5a2fdaa27796502daf0fb2314e599b76049296d4 1 parent d9239fd
@drogus drogus authored
Showing with 14 additions and 2 deletions.
  1. +4 −2 railties/lib/rails/engine.rb
  2. +10 −0 railties/test/unit/engine_test.rb
View
6 railties/lib/rails/engine.rb
@@ -486,8 +486,10 @@ def env_config
end
def routes
- @routes ||= ActionDispatch::Routing::RouteSet.new
- @routes.draw_paths.concat paths["config/routes"].paths
+ @routes ||= ActionDispatch::Routing::RouteSet.new.tap do |routes|
+ routes.draw_paths.concat paths["config/routes"].paths
+ end
+
@routes.append(&Proc.new) if block_given?
@routes
end
View
10 railties/test/unit/engine_test.rb
@@ -12,5 +12,15 @@ def initialize(*args)
assert !engine.routes?
end
+
+ it "does not add more paths to routes on each call" do
+ engine = Class.new(Rails::Engine)
+
+ engine.routes
+ length = engine.routes.draw_paths.length
+
+ engine.routes
+ assert_equal length, engine.routes.draw_paths.length
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.