Browse files

Calling `follow_redirect!` does not reset the `html_document`:

- When making a request to a controller that redirects, `follow_redirect!` would not reset the `html_document` ivar, it only resets the `html_document` ivar from the session (not the runner)
- If one was doing something like this;
    get '/redirect'
    assert_select 'you are being redirected'
    # html_document is memoized and doesn't get reset
- To fix the issue we can do the same for any other methods (`get`, `post`...) and define a method in the runner that delegates to the session but clears the html_document_first
- Fixes #29367
  • Loading branch information...
Edouard-chin committed Jun 23, 2017
1 parent 98d12f1 commit 2508c7de267794781efb6d5f61d293c650d3d6e5
@@ -338,7 +338,7 @@ def remove! # :nodoc:
@integration_session = nil
%w(get post patch put head delete cookies assigns).each do |method|
%w(get post patch put head delete cookies assigns follow_redirect!).each do |method|
define_method(method) do |*args|
# reset the html_document variable, except for cookies/assigns calls
unless method == "cookies" || method == "assigns"
@@ -335,6 +335,18 @@ def test_redirect
def test_redirect_reset_html_document
with_test_route_set do
get "/redirect"
previous_html_document = html_document
assert_response :ok
refute_same previous_html_document, html_document
def test_xml_http_request_get
with_test_route_set do
get "/get", xhr: true

0 comments on commit 2508c7d

Please sign in to comment.