Topic: xml_http_request followed by follow_redirect!

In my view, I have a periodically_call_remote which then redirects the user to a different page based on some condition.

In order to test this in my integration file I tried issuing an xml_http_request followed by a follow_redirect!. 
Unfortunately this gives me a RuntimeError telling me that the response wasn't a redirect.

My program works when I run it in a browser, I just can't get the integration test to work.

Re: xml_http_request followed by follow_redirect!

I've learned that it depends on where I put the page.redirect.  If I put page.redirect in the controller the integration test passes, but the page doesn't reload when I run it in a browser.  On the other hand, if I put the page.redirect in an RJS the page reloads, but the integration test fails.

Last edited by ToddG (2011-10-09 20:36:03)

Re: xml_http_request followed by follow_redirect!

It looks like Integration::Session doesn't evaluate JavaScript returned from a page request.  Therefore, I had to check that the response I got back was the desired JavaScript.  I then had to tell the session object to fetch the new page.

session.xml_http_request :post, 'site/get_new_page'
session.assert_equal session.response.body, 'window.location.href = "/site/new_page";'
session.get "/site/new_page"

Last edited by ToddG (2011-10-10 01:34:16)