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

Fix AP tests related to routes inspector output and the new column titles

This commit is contained in:
Carlos Antonio da Silva 2013-02-19 08:58:29 -03:00
parent f99453071b
commit 66237cd2b7

View file

@ -44,35 +44,45 @@ module ActionDispatch
mount engine => "/blog", :as => "blog" mount engine => "/blog", :as => "blog"
end end
expected = [ assert_equal [
" Prefix Verb URI Pattern Controller#Action",
"custom_assets GET /custom/assets(.:format) custom_assets#show", "custom_assets GET /custom/assets(.:format) custom_assets#show",
" blog /blog Blog::Engine", " blog /blog Blog::Engine",
"", "",
"Routes for Blog::Engine:", "Routes for Blog::Engine:",
"cart GET /cart(.:format) cart#show" "cart GET /cart(.:format) cart#show"
] ], output
assert_equal expected, output
end 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'
end end
assert_equal ["cart GET /cart(.:format) cart#show"], output
assert_equal [
"Prefix Verb URI Pattern Controller#Action",
"cart GET /cart(.:format) cart#show"
], output
end end
def test_inspect_shows_custom_assets def test_inspect_shows_custom_assets
output = draw do output = draw do
get '/custom/assets', :to => 'custom_assets#show' get '/custom/assets', :to => 'custom_assets#show'
end end
assert_equal ["custom_assets GET /custom/assets(.:format) custom_assets#show"], output
assert_equal [
" Prefix Verb URI Pattern Controller#Action",
"custom_assets GET /custom/assets(.:format) custom_assets#show"
], output
end end
def test_inspect_routes_shows_resources_route def test_inspect_routes_shows_resources_route
output = draw do output = draw do
resources :articles resources :articles
end end
expected = [
assert_equal [
" Prefix Verb URI Pattern Controller#Action",
" articles GET /articles(.:format) articles#index", " articles GET /articles(.:format) articles#index",
" POST /articles(.:format) articles#create", " POST /articles(.:format) articles#create",
" new_article GET /articles/new(.:format) articles#new", " new_article GET /articles/new(.:format) articles#new",
@ -80,50 +90,74 @@ module ActionDispatch
" article GET /articles/:id(.:format) articles#show", " article GET /articles/:id(.:format) articles#show",
" PATCH /articles/:id(.:format) articles#update", " PATCH /articles/:id(.:format) articles#update",
" PUT /articles/:id(.:format) articles#update", " PUT /articles/:id(.:format) articles#update",
" DELETE /articles/:id(.:format) articles#destroy" ] " DELETE /articles/:id(.:format) articles#destroy"
assert_equal expected, output ], output
end end
def test_inspect_routes_shows_root_route def test_inspect_routes_shows_root_route
output = draw do output = draw do
root :to => 'pages#main' root :to => 'pages#main'
end end
assert_equal ["root GET / pages#main"], output
assert_equal [
"Prefix Verb URI Pattern Controller#Action",
"root GET / pages#main"
], output
end end
def test_inspect_routes_shows_dynamic_action_route def test_inspect_routes_shows_dynamic_action_route
output = draw do output = draw do
get 'api/:action' => 'api' get 'api/:action' => 'api'
end end
assert_equal [" GET /api/:action(.:format) api#:action"], output
assert_equal [
"Prefix Verb URI Pattern Controller#Action",
" GET /api/:action(.:format) api#:action"
], output
end end
def test_inspect_routes_shows_controller_and_action_only_route def test_inspect_routes_shows_controller_and_action_only_route
output = draw do output = draw do
get ':controller/:action' get ':controller/:action'
end end
assert_equal [" GET /:controller/:action(.:format) :controller#:action"], output
assert_equal [
"Prefix Verb URI Pattern Controller#Action",
" GET /:controller/:action(.:format) :controller#:action"
], output
end end
def test_inspect_routes_shows_controller_and_action_route_with_constraints def test_inspect_routes_shows_controller_and_action_route_with_constraints
output = draw do output = draw do
get ':controller(/:action(/:id))', :id => /\d+/ get ':controller(/:action(/:id))', :id => /\d+/
end end
assert_equal [" GET /:controller(/:action(/:id))(.:format) :controller#:action {:id=>/\\d+/}"], output
assert_equal [
"Prefix Verb URI Pattern Controller#Action",
" GET /:controller(/:action(/:id))(.:format) :controller#:action {:id=>/\\d+/}"
], output
end end
def test_rake_routes_shows_route_with_defaults def test_rake_routes_shows_route_with_defaults
output = draw do output = draw do
get 'photos/:id' => 'photos#show', :defaults => {:format => 'jpg'} get 'photos/:id' => 'photos#show', :defaults => {:format => 'jpg'}
end end
assert_equal [%Q[ GET /photos/:id(.:format) photos#show {:format=>"jpg"}]], output
assert_equal [
"Prefix Verb URI Pattern Controller#Action",
%Q[ GET /photos/:id(.:format) photos#show {:format=>"jpg"}]
], output
end end
def test_rake_routes_shows_route_with_constraints def test_rake_routes_shows_route_with_constraints
output = draw do output = draw do
get 'photos/:id' => 'photos#show', :id => /[A-Z]\d{5}/ get 'photos/:id' => 'photos#show', :id => /[A-Z]\d{5}/
end end
assert_equal [" GET /photos/:id(.:format) photos#show {:id=>/[A-Z]\\d{5}/}"], output
assert_equal [
"Prefix Verb URI Pattern Controller#Action",
" GET /photos/:id(.:format) photos#show {:id=>/[A-Z]\\d{5}/}"
], output
end end
class RackApp class RackApp
@ -135,7 +169,11 @@ module ActionDispatch
output = draw do output = draw do
get 'foo/:id' => RackApp, :id => /[A-Z]\d{5}/ get 'foo/:id' => RackApp, :id => /[A-Z]\d{5}/
end end
assert_equal [" GET /foo/:id(.:format) #{RackApp.name} {:id=>/[A-Z]\\d{5}/}"], output
assert_equal [
"Prefix Verb URI Pattern Controller#Action",
" GET /foo/:id(.:format) #{RackApp.name} {:id=>/[A-Z]\\d{5}/}"
], output
end end
def test_rake_routes_shows_route_with_rack_app_nested_with_dynamic_constraints def test_rake_routes_shows_route_with_rack_app_nested_with_dynamic_constraints
@ -151,7 +189,10 @@ module ActionDispatch
end end
end end
assert_equal [" /foo #{RackApp.name} {:constraint=>( my custom constraint )}"], output assert_equal [
"Prefix Verb URI Pattern Controller#Action",
" /foo #{RackApp.name} {:constraint=>( my custom constraint )}"
], output
end end
def test_rake_routes_dont_show_app_mounted_in_assets_prefix def test_rake_routes_dont_show_app_mounted_in_assets_prefix
@ -169,9 +210,12 @@ module ActionDispatch
get "/foobar" => redirect{ "/foo/bar" } get "/foobar" => redirect{ "/foo/bar" }
end end
assert_equal " foo GET /foo(.:format) redirect(301, /foo/bar) {:subdomain=>\"admin\"}", output[0] assert_equal [
assert_equal " bar GET /bar(.:format) redirect(307, path: /foo/bar)", output[1] "Prefix Verb URI Pattern Controller#Action",
assert_equal "foobar GET /foobar(.:format) redirect(301)", output[2] " foo GET /foo(.:format) redirect(301, /foo/bar) {:subdomain=>\"admin\"}",
" bar GET /bar(.:format) redirect(307, path: /foo/bar)",
"foobar GET /foobar(.:format) redirect(301)"
], output
end end
def test_routes_can_be_filtered def test_routes_can_be_filtered
@ -180,7 +224,8 @@ module ActionDispatch
resources :posts resources :posts
end end
assert_equal [" posts GET /posts(.:format) posts#index", assert_equal [" Prefix Verb URI Pattern Controller#Action",
" posts GET /posts(.:format) posts#index",
" POST /posts(.:format) posts#create", " POST /posts(.:format) posts#create",
" new_post GET /posts/new(.:format) posts#new", " new_post GET /posts/new(.:format) posts#new",
"edit_post GET /posts/:id/edit(.:format) posts#edit", "edit_post GET /posts/:id/edit(.:format) posts#edit",