Permalink
Browse files

Merge pull request #13811 from mdesantis/issue-13810

Fixes #13810 `rake routes` error when mount `Rails::Engine` with empty routes
Conflicts:
	actionpack/CHANGELOG.md
  • Loading branch information...
1 parent e3130a3 commit 4b85b3fc4d5e52ca8d9bb9b9213c70c885bdb763 @senny senny committed Jan 24, 2014
View
@@ -1,3 +1,9 @@
+* Fix `rake routes` error when `Rails::Engine` with empty routes is mounted.
+
+ Fixes #13810.
+
+ *Maurizio De Santis*
+
* Unique the segment keys array for non-optimized url helpers
In Rails 3.2 you only needed pass an argument for dynamic segment once so
@@ -194,9 +194,9 @@ def draw_header(routes)
end
def widths(routes)
- [routes.map { |r| r[:name].length }.max,
- routes.map { |r| r[:verb].length }.max,
- routes.map { |r| r[:path].length }.max]
+ [routes.map { |r| r[:name].length }.max || 0,
+ routes.map { |r| r[:verb].length }.max || 0,
+ routes.map { |r| r[:path].length }.max || 0]
end
end
@@ -54,6 +54,27 @@ def self.inspect
], output
end
+ def test_displaying_routes_for_engines_without_routes
+ engine = Class.new(Rails::Engine) do
+ def self.inspect
+ "Blog::Engine"
+ end
+ end
+ engine.routes.draw do
+ end
+
+ output = draw do
+ mount engine => "/blog", as: "blog"
+ end
+
+ assert_equal [
+ "Prefix Verb URI Pattern Controller#Action",
+ " blog /blog Blog::Engine",
+ "",
+ "Routes for Blog::Engine:"
+ ], output
+ end
+
def test_cart_inspect
output = draw do
get '/cart', :to => 'cart#show'

0 comments on commit 4b85b3f

Please sign in to comment.