Given a freshly created edge app and a controller (e.g.
Posts) that just redirects one URL to another URL
(e.g. /posts/private =302=> /posts/index ) the
following simple steps in an Integration story fail.
get '/posts/private'
assert_response :redirect # passes
follow_redirect! # should try to get /posts/index
assert_response :success # fails with a 404
What happens is that no matter what the URL
follow_redirect! always tries to get /h
which is actually the wrongly interpreted first character of
http://www.example.com/posts/index
I've tracked the issue down to line 129 of
integration.rb:
get(interpret_uri(headers['location'].first))
The bug seems to have appeared after this commit:
http://github.com/rails/rails/co...
Before these Rack related changes, calling
headers['location'] would return an Array of Strings.
Now it returns a single String (in my case http://www.example.com/posts/index)
and calling first on it returns the first character.
Removing the call to first makes my integration story pass but
raises an error in line 35 of integration_test.rb
(test_follow_redirect_calls_get_and_returns_status):
@session.stubs(:headers).returns({"location" => ["www.google.com"]})
The test can be fixed by removing the square brackets i.e. make
headers['location'] stub return an String.
I am almost certain that the test needs fixing because line 342
of Rack's lint.rb
(Rake::Lint#check_headers) that states that "header
values must consist of Strings" and it seems to be exactly what is
returned from the @app.call(env)
http://github.com/chneukirchen/r...
I am attaching a tiny patch for this with no extra tests, just
the corrected ones, as the dispatch code is way over my head and I
can't seem to find a way to test it more end to end. Testing with
stubs seems to have hidden the bug in this case...