diff options
author | Łukasz Strzałkowski <lukasz.strzalkowski@gmail.com> | 2012-05-18 23:21:20 +0200 |
---|---|---|
committer | Łukasz Strzałkowski <lukasz.strzalkowski@gmail.com> | 2012-05-18 23:55:39 +0200 |
commit | 5f7bfb77786ab02db213f9563c199fc5b7f53f3e (patch) | |
tree | cea3442789306f3f3e0ce225c9a98c8ddc1a7225 /railties | |
parent | 61fc10d23382c7ba57c67391063a2113fb3f2abc (diff) | |
download | rails-5f7bfb77786ab02db213f9563c199fc5b7f53f3e.tar.gz rails-5f7bfb77786ab02db213f9563c199fc5b7f53f3e.tar.bz2 rails-5f7bfb77786ab02db213f9563c199fc5b7f53f3e.zip |
Fix inspecting route redirections, closes #6369
This commit fixes route inspection in `rake routes`
Before:
foo /foo(.:format) :controller#:action"
After:
foo /foo(.:format) Redirect (301)
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/application/route_inspector.rb | 4 | ||||
-rw-r--r-- | railties/test/application/route_inspect_test.rb | 9 |
2 files changed, 11 insertions, 2 deletions
diff --git a/railties/lib/rails/application/route_inspector.rb b/railties/lib/rails/application/route_inspector.rb index 1e5ce67a58..845c54f416 100644 --- a/railties/lib/rails/application/route_inspector.rb +++ b/railties/lib/rails/application/route_inspector.rb @@ -16,7 +16,7 @@ module Rails class_name = app.class.name.to_s if class_name == "ActionDispatch::Routing::Mapper::Constraints" rack_app(app.app) - elsif class_name !~ /^ActionDispatch::Routing/ + elsif class_name == "ActionDispatch::Routing::Redirect" || class_name !~ /^ActionDispatch::Routing/ app end end @@ -67,7 +67,7 @@ module Rails @engines = Hash.new end - def format all_routes, filter = nil + def format(all_routes, filter = nil) if filter all_routes = all_routes.select{ |route| route.defaults[:controller] == filter } end diff --git a/railties/test/application/route_inspect_test.rb b/railties/test/application/route_inspect_test.rb index 94871c3759..31af1ca6dc 100644 --- a/railties/test/application/route_inspect_test.rb +++ b/railties/test/application/route_inspect_test.rb @@ -152,5 +152,14 @@ module ApplicationTests assert_no_match(/RackApp/, output.first) assert_no_match(/\/sprockets/, output.first) end + + def test_redirect + output = draw do + match '/foo' => redirect("/bar") + match '/foo2' => redirect("/bar", status: 307) + end + assert_equal " foo /foo(.:format) Redirect (301)", output[0] + assert_equal "foo2 /foo2(.:format) Redirect (307)", output[1] + end end end |