While following Agile2's example code, I had a test method such that:
def test_index
get :index
assert_redirected_to :action => 'login'
assert flash[:notice] == 'Please log in'
end
And in the controller, I had:
def authorize
unless User.find_by_id(session[:user_id])
session[:original_uri] = request.request_uri
flash[:notice] = 'Please log in'
redirect_to :controller => :login, :action => :login
end
end
I'm not entirely sure this should work, but redirect_to seems to work the same with 'login' or :login. It's just the test that crashes in the symbol case.
What I get is:
NoMethodError: undefined method first' for :login:Symbol (...) action_controller/assertions/response_assertions.rb:72:in assert_redirected_to'