rails/rails — pull request #6922 by andrewferk (2012-07-01 18:32:21+00:00)
Title: Allow assert_recognizes and recognize_path to support url redirects from...

Currently, there is no way to unit test the Redirection module in ActionDispatch::Routing. Also, redirects are not recognized as paths using `recognize_path`. These problems lead to a potential false positive. If you have this routing:
```ruby
get 'help' => redirect('http://help.example.org/')
get 'help' => 'help#index'
```
and this test:
```ruby
test "should recognize /help as help#index" do
assert_recognizes({:controller => 'help', :action => 'index'}, '/help')
end
```
the test passes, but actually, it should recognize /help as a redirect.

With this commit, it fixes the false negative and allows for url redirection:
```ruby
get 'help' => redirect("http://example.org/")
assert_recognizes("http://example.org/", "/help")
```
This is just a start to fix this issue, as the Redirection module offers much more than just external url redirection. Would definitely be willing to discuss other ways to unit test redirection; however, i think it is a bug that assert_recognizes does not recognize redirection routes.

More referenced here.