aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/rails/engine.rb6
-rw-r--r--railties/test/unit/engine_test.rb10
2 files changed, 14 insertions, 2 deletions
diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb
index d81f9cf7ff..d4f632702c 100644
--- a/railties/lib/rails/engine.rb
+++ b/railties/lib/rails/engine.rb
@@ -486,8 +486,10 @@ module Rails
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
diff --git a/railties/test/unit/engine_test.rb b/railties/test/unit/engine_test.rb
index 977f46ecea..02d40d97f6 100644
--- a/railties/test/unit/engine_test.rb
+++ b/railties/test/unit/engine_test.rb
@@ -12,5 +12,15 @@ module Unit
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