aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/application/route_inspect_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'railties/test/application/route_inspect_test.rb')
-rw-r--r--railties/test/application/route_inspect_test.rb42
1 files changed, 29 insertions, 13 deletions
diff --git a/railties/test/application/route_inspect_test.rb b/railties/test/application/route_inspect_test.rb
index fcfa87e395..453ba8196c 100644
--- a/railties/test/application/route_inspect_test.rb
+++ b/railties/test/application/route_inspect_test.rb
@@ -8,6 +8,12 @@ module ApplicationTests
def setup
@set = ActionDispatch::Routing::RouteSet.new
@inspector = Rails::Application::RouteInspector.new
+ app = ActiveSupport::OrderedOptions.new
+ app.config = ActiveSupport::OrderedOptions.new
+ app.config.assets = ActiveSupport::OrderedOptions.new
+ app.config.assets.prefix = '/sprockets'
+ Rails.stubs(:application).returns(app)
+ Rails.stubs(:env).returns("development")
end
def test_displaying_routes_for_engines
@@ -62,6 +68,7 @@ module ApplicationTests
" new_article GET /articles/new(.:format) articles#new",
"edit_article GET /articles/:id/edit(.:format) articles#edit",
" article GET /articles/:id(.:format) articles#show",
+ " PATCH /articles/:id(.:format) articles#update",
" PUT /articles/:id(.:format) articles#update",
" DELETE /articles/:id(.:format) articles#destroy" ]
assert_equal expected, output
@@ -72,47 +79,47 @@ module ApplicationTests
root :to => 'pages#main'
end
output = @inspector.format @set.routes
- assert_equal ["root / pages#main"], output
+ assert_equal ["root GET / pages#main"], output
end
def test_inspect_routes_shows_dynamic_action_route
@set.draw do
- match 'api/:action' => 'api'
+ get 'api/:action' => 'api'
end
output = @inspector.format @set.routes
- assert_equal [" /api/:action(.:format) api#:action"], output
+ assert_equal [" GET /api/:action(.:format) api#:action"], output
end
def test_inspect_routes_shows_controller_and_action_only_route
@set.draw do
- match ':controller/:action'
+ get ':controller/:action'
end
output = @inspector.format @set.routes
- assert_equal [" /:controller/:action(.:format) :controller#:action"], output
+ assert_equal [" GET /:controller/:action(.:format) :controller#:action"], output
end
def test_inspect_routes_shows_controller_and_action_route_with_constraints
@set.draw do
- match ':controller(/:action(/:id))', :id => /\d+/
+ get ':controller(/:action(/:id))', :id => /\d+/
end
output = @inspector.format @set.routes
- assert_equal [" /:controller(/:action(/:id))(.:format) :controller#:action {:id=>/\\d+/}"], output
+ assert_equal [" GET /:controller(/:action(/:id))(.:format) :controller#:action {:id=>/\\d+/}"], output
end
def test_rake_routes_shows_route_with_defaults
@set.draw do
- match 'photos/:id' => 'photos#show', :defaults => {:format => 'jpg'}
+ get 'photos/:id' => 'photos#show', :defaults => {:format => 'jpg'}
end
output = @inspector.format @set.routes
- assert_equal [%Q[ /photos/:id(.:format) photos#show {:format=>"jpg"}]], output
+ assert_equal [%Q[ GET /photos/:id(.:format) photos#show {:format=>"jpg"}]], output
end
def test_rake_routes_shows_route_with_constraints
@set.draw do
- match 'photos/:id' => 'photos#show', :id => /[A-Z]\d{5}/
+ get 'photos/:id' => 'photos#show', :id => /[A-Z]\d{5}/
end
output = @inspector.format @set.routes
- assert_equal [" /photos/:id(.:format) photos#show {:id=>/[A-Z]\\d{5}/}"], output
+ assert_equal [" GET /photos/:id(.:format) photos#show {:id=>/[A-Z]\\d{5}/}"], output
end
class RackApp
@@ -122,10 +129,10 @@ module ApplicationTests
def test_rake_routes_shows_route_with_rack_app
@set.draw do
- match 'foo/:id' => RackApp, :id => /[A-Z]\d{5}/
+ get 'foo/:id' => RackApp, :id => /[A-Z]\d{5}/
end
output = @inspector.format @set.routes
- assert_equal [" /foo/:id(.:format) #{RackApp.name} {:id=>/[A-Z]\\d{5}/}"], output
+ assert_equal [" GET /foo/:id(.:format) #{RackApp.name} {:id=>/[A-Z]\\d{5}/}"], output
end
def test_rake_routes_shows_route_with_rack_app_nested_with_dynamic_constraints
@@ -144,5 +151,14 @@ module ApplicationTests
output = @inspector.format @set.routes
assert_equal [" /foo #{RackApp.name} {:constraint=>( my custom constraint )}"], output
end
+
+ def test_rake_routes_dont_show_app_mounted_in_assets_prefix
+ @set.draw do
+ get '/sprockets' => RackApp
+ end
+ output = @inspector.format @set.routes
+ assert_no_match(/RackApp/, output.first)
+ assert_no_match(/\/sprockets/, output.first)
+ end
end
end