diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-07-08 13:15:53 -0300 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-07-08 13:20:24 -0300 |
commit | 21c5bc9260a31440cad994f001c7ef6675d44a1d (patch) | |
tree | 05d89bd3017401391d1e17f78102c32708982d4b /railties/test | |
parent | 15d80ebb0a59d04aa9d5032d93ff7e090a8d17a1 (diff) | |
download | rails-21c5bc9260a31440cad994f001c7ef6675d44a1d.tar.gz rails-21c5bc9260a31440cad994f001c7ef6675d44a1d.tar.bz2 rails-21c5bc9260a31440cad994f001c7ef6675d44a1d.zip |
Remove RoutesInspector from railties, since it was moved to AP
Changes introduced in 7404cda9f61e41d52ce244d60abbf598684a96c4.
Fix railties build.
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/application/routes_inspect_test.rb | 168 |
1 files changed, 0 insertions, 168 deletions
diff --git a/railties/test/application/routes_inspect_test.rb b/railties/test/application/routes_inspect_test.rb deleted file mode 100644 index 68a8afc93e..0000000000 --- a/railties/test/application/routes_inspect_test.rb +++ /dev/null @@ -1,168 +0,0 @@ -require 'minitest/autorun' -require 'rails/application/routes_inspector' -require 'action_controller' -require 'rails/engine' - -module ApplicationTests - class RoutesInspectTest < ActiveSupport::TestCase - def setup - @set = ActionDispatch::Routing::RouteSet.new - @inspector = Rails::Application::RoutesInspector.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 draw(&block) - @set.draw(&block) - @inspector.format(@set.routes) - end - - def test_displaying_routes_for_engines - engine = Class.new(Rails::Engine) do - def self.to_s - "Blog::Engine" - end - end - engine.routes.draw do - get '/cart', :to => 'cart#show' - end - - output = draw do - get '/custom/assets', :to => 'custom_assets#show' - mount engine => "/blog", :as => "blog" - end - - expected = [ - "custom_assets GET /custom/assets(.:format) custom_assets#show", - " blog /blog Blog::Engine", - "\nRoutes for Blog::Engine:", - "cart GET /cart(.:format) cart#show" - ] - assert_equal expected, output - end - - def test_cart_inspect - output = draw do - get '/cart', :to => 'cart#show' - end - assert_equal ["cart GET /cart(.:format) cart#show"], output - end - - def test_inspect_shows_custom_assets - output = draw do - get '/custom/assets', :to => 'custom_assets#show' - end - assert_equal ["custom_assets GET /custom/assets(.:format) custom_assets#show"], output - end - - def test_inspect_routes_shows_resources_route - output = draw do - resources :articles - end - expected = [ - " articles GET /articles(.:format) articles#index", - " POST /articles(.:format) articles#create", - " 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 - end - - def test_inspect_routes_shows_root_route - output = draw do - root :to => 'pages#main' - end - assert_equal ["root GET / pages#main"], output - end - - def test_inspect_routes_shows_dynamic_action_route - output = draw do - get 'api/:action' => 'api' - end - assert_equal [" GET /api/:action(.:format) api#:action"], output - end - - def test_inspect_routes_shows_controller_and_action_only_route - output = draw do - get ':controller/:action' - end - assert_equal [" GET /:controller/:action(.:format) :controller#:action"], output - end - - def test_inspect_routes_shows_controller_and_action_route_with_constraints - output = draw do - get ':controller(/:action(/:id))', :id => /\d+/ - end - assert_equal [" GET /:controller(/:action(/:id))(.:format) :controller#:action {:id=>/\\d+/}"], output - end - - def test_rake_routes_shows_route_with_defaults - output = draw do - get 'photos/:id' => 'photos#show', :defaults => {:format => 'jpg'} - end - assert_equal [%Q[ GET /photos/:id(.:format) photos#show {:format=>"jpg"}]], output - end - - def test_rake_routes_shows_route_with_constraints - output = draw do - get 'photos/:id' => 'photos#show', :id => /[A-Z]\d{5}/ - end - assert_equal [" GET /photos/:id(.:format) photos#show {:id=>/[A-Z]\\d{5}/}"], output - end - - class RackApp - def self.call(env) - end - end - - def test_rake_routes_shows_route_with_rack_app - output = draw do - get 'foo/:id' => RackApp, :id => /[A-Z]\d{5}/ - end - 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 - constraint = Class.new do - def to_s - "( my custom constraint )" - end - end - - output = draw do - scope :constraint => constraint.new do - mount RackApp => '/foo' - end - end - - assert_equal [" /foo #{RackApp.name} {:constraint=>( my custom constraint )}"], output - end - - def test_rake_routes_dont_show_app_mounted_in_assets_prefix - output = draw do - get '/sprockets' => RackApp - end - assert_no_match(/RackApp/, output.first) - assert_no_match(/\/sprockets/, output.first) - end - - def test_redirect - output = draw do - get "/foo" => redirect("/foo/bar"), :constraints => { :subdomain => "admin" } - get "/bar" => redirect(path: "/foo/bar", status: 307) - get "/foobar" => redirect{ "/foo/bar" } - end - - assert_equal " foo GET /foo(.:format) redirect(301, /foo/bar) {:subdomain=>\"admin\"}", output[0] - assert_equal " bar GET /bar(.:format) redirect(307, path: /foo/bar)", output[1] - assert_equal "foobar GET /foobar(.:format) redirect(301)", output[2] - end - end -end |