diff options
-rw-r--r-- | railties/lib/rails/tasks/routes.rake | 6 | ||||
-rw-r--r-- | railties/test/application/rake_test.rb | 21 |
2 files changed, 24 insertions, 3 deletions
diff --git a/railties/lib/rails/tasks/routes.rake b/railties/lib/rails/tasks/routes.rake index adc005769f..0c26bcf790 100644 --- a/railties/lib/rails/tasks/routes.rake +++ b/railties/lib/rails/tasks/routes.rake @@ -10,12 +10,12 @@ task :routes => :environment do routes = all_routes.collect do |route| reqs = route.requirements.dup - reqs[:to] = route.app unless route.app.class.name.to_s =~ /^ActionDispatch::Routing/ + rack_app = route.app unless route.app.class.name.to_s =~ /^ActionDispatch::Routing/ - controller_action = "#{reqs[:controller]}##{reqs[:action]}" + endpoint = rack_app ? rack_app.inspect : "#{reqs[:controller]}##{reqs[:action]}" constraints = reqs.except(:controller, :action) - reqs = controller_action == '#' ? '' : controller_action + reqs = endpoint == '#' ? '' : endpoint unless constraints.empty? reqs = reqs.empty? ? constraints.inspect : "#{reqs} #{constraints.inspect}" diff --git a/railties/test/application/rake_test.rb b/railties/test/application/rake_test.rb index 6988b2541d..cc65a674c9 100644 --- a/railties/test/application/rake_test.rb +++ b/railties/test/application/rake_test.rb @@ -166,6 +166,27 @@ module ApplicationTests assert_equal " /photos/:id(.:format) photos#show {:id=>/[A-Z]\\d{5}/}\n", Dir.chdir(app_path){ `rake routes` } end + def test_rake_routes_shows_route_with_rack_app + app_file "lib/rack_app.rb", <<-RUBY + class RackApp + class << self + def call(env) + end + end + end + RUBY + + app_file "config/routes.rb", <<-RUBY + require 'rack_app' + + AppTemplate::Application.routes.draw do + match 'foo/:id' => RackApp, :id => /[A-Z]\\d{5}/ + end + RUBY + + assert_equal " /foo/:id(.:format) RackApp {:id=>/[A-Z]\\d{5}/}\n", Dir.chdir(app_path){ `rake routes` } + end + def test_logger_is_flushed_when_exiting_production_rake_tasks add_to_config <<-RUBY rake_tasks do |