I wrote a small test to check redirecting and URL parameters. Strangely the test fails, even though the error message seems to indicate the result is actually correct:
Failure/Error: response.should redirect_to(movies_path(:sort => 'title'))
Expected response to be a redirect to
<http://test.host/movies?sort=title>
but was a redirect to
<http://test.host/movies?ratings%5BG%5D=G&ratings%5BNC-17%5D=NC-17&ratings%5BPG%5D=PG&ratings%5BPG-13%5D=PG-13&ratings%5BR%5D=R&sort=title>
The URLs are identical (as they should be) and the expected parameter 'sort=title' is included in the parameters of the actual result. I believe this is a valid situation...
Acoording to http://api.rubyonrails.org/classes/ActionDispatch/Assertions/ResponseAssertions.html#method-i-assert_redirected_to: "This match can be partial, such that assert_redirected_to(controller: "weblog") will also match the redirection of redirect_to(controller: "weblog", action: "show") and so on."
SOLUTION:
I was not able to get the proposal of the selected answer to work, but the reply was useful in explaining that the 'partial' match in the above link is somewhat misleading, and the code did not work as expected. So, I created a Hash
with all the parameters received, and added them to the 'should redirect_to' test:
response.should redirect_to(movies_path(:sort => 'title', :ratings => rest))
where 'rest' is that hash.