1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix rake routes error when Rails::Engine with empty routes is mounted; fixes rails/rails#13810

Squash
This commit is contained in:
Maurizio De Santis 2014-01-23 14:50:29 +01:00 committed by Maurizio De Santis
parent 6ef0569b0b
commit c1f8a0d614
3 changed files with 30 additions and 3 deletions

View file

@ -1,3 +1,9 @@
* Fix `rake routes` error when `Rails::Engine` with empty routes is mounted.
Fixes #13810.
*Maurizio De Santis*
* Automatically convert dashes to underscores for shorthand routes, e.g: * Automatically convert dashes to underscores for shorthand routes, e.g:
get '/our-work/latest' get '/our-work/latest'

View file

@ -194,9 +194,9 @@ module ActionDispatch
end end
def widths(routes) def widths(routes)
[routes.map { |r| r[:name].length }.max, [routes.map { |r| r[:name].length }.max || 0,
routes.map { |r| r[:verb].length }.max, routes.map { |r| r[:verb].length }.max || 0,
routes.map { |r| r[:path].length }.max] routes.map { |r| r[:path].length }.max || 0]
end end
end end

View file

@ -54,6 +54,27 @@ module ActionDispatch
], output ], output
end 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 def test_cart_inspect
output = draw do output = draw do
get '/cart', :to => 'cart#show' get '/cart', :to => 'cart#show'