Topic: request_uri not reset on 2nd request in functional test

I have a functional test that tests controllers which require authentication. So, the first thing I do is to login a user. I then continue testing my controllers, which make use of request.request_uri. However, the request_uri is keeping the result of the previous login post. I have found a hack of explicitly setting the env['REQUEST_URI']. Is there a better workaround?

  def test_verification_required
    # now check a verification required page
    post :login, :user=>{ :username => "nvtest", :password => "test"}
    assert_response :redirect
    assert_session_has :user
    assert_redirected_to 'user/welcome'
    # HACK. The framework seems to have problems with not setting
    # REQUEST_URI correctly when making multiple requests
    get :vr_test
    assert !session[:user].verified?
    assert flash[:warning]
    assert_response :redirect
    assert_equal "/user/vr_test", @request.env['REQUEST_URI']
    assert_equal "/user/vr_test", session[:return_to]
    assert_redirected_to :action => 'verify'
    post :verify, :email => session[:user].email, :verification_key => session[:
    assert_response :redirect
    assert flash[:message]
    assert session[:user].verified?
    assert_redirected_to "user/vr_test"
    assert_nil session[:return_to]
    get :vr_test
    assert_response :success
    assert flash.empty?
    assert_template "user/vr_test"

Re: request_uri not reset on 2nd request in functional test

Someone correct me if I'm off on this but ... I don't think functional tests are intended to be used with multiple requests.

In contrast, integration tests definitely are designed to mimic a user walking through a site.