Integration tests - 1.1


#1

Iâ??m using the new 1.1 integration test facilityâ?¦ Iâ??m trying to write a
test that sees if a controller redirects to the correct place and
preserves the query string.

Hereâ??s the code:

class LoginRedirectTest < ActionController::IntegrationTest

def test_non_admin_auth

request_uri = "/datafeed/event/report?blah=blah"

get(request_uri)

follow_redirect!

assert_response :success

status = post("/login/authenticate", :login_info => {:user_name => 

“blah”, :password => “blah”})

follow_redirect!

assert_response :success

user = session[:user]

assert !user.nil?

puts response[“REQUEST_URI”]

assert_equal(request_uri, response [“REQUEST_URI”])

end

The last two lines donâ??t workâ?¦ I can see REQUEST_URL in the @attributes
of the response and it contains the correct uri
("/datafeed/event/report?blah=blah"), but I canâ??t figure out how to
access it. I also havenâ??t been able to locate the source code for the
response (CgiResponse). Can someone point me in the right direction?

Thanks,

phil


#2

Phil,

Do you mean “request”? The response object doesn’t encapsulate a
request_uri attribute. With the request object, you can do:

request.request_uri

In general, the request environment can be accessed via:

request.env

(That’s a Hash instance.)

Hope that helps,

Jamis