This post originated from an RSS feed registered with Ruby Buzz
by Matthew Bass.
Original Post: No need to check response when testing redirects
Feed Title: Pelargir
Feed URL: http://feeds.feedburner.com/pelargir/
Feed Description: Musings on software and life from Matthew Bass. Regular posts on new web products, tips and tricks, etc.
Early on in my exploration of Rails, I got into the habit of testing that the response code of an action indicated a redirect. It turns out that this check is entirely unnecessary since assert_redirected_to makes an identical check:
def assert_redirected_to(options = {}, message=nil)
clean_backtrace do
assert_response(:redirect, message)
...
end
end
This is how one of my functional tests might have looked [...]