Given a controller action that performs a redirect_to :back, and a test that inherits from ActionDispatch::IntegrationTest and tries toassert_redirected_to previous url, we can do the following:
test 'put update object' do
put update_object_path(object), {}, { 'HTTP_REFERER' => ‘path_to_be_redirected_to' }
assert_redirected_to path_to_be_redirected_to
end
Then we must only adjust path_to_be_redirected_to to that previous url we want.