From 2508c7de267794781efb6d5f61d293c650d3d6e5 Mon Sep 17 00:00:00 2001 From: Edouard CHIN Date: Fri, 23 Jun 2017 15:41:35 -0400 Subject: 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; ```ruby get '/redirect' assert_select 'you are being redirected' follow_redirect! # 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 --- actionpack/lib/action_dispatch/testing/integration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/lib/action_dispatch/testing/integration.rb') diff --git a/actionpack/lib/action_dispatch/testing/integration.rb b/actionpack/lib/action_dispatch/testing/integration.rb index 4973a8f2f2..f16647fac8 100644 --- a/actionpack/lib/action_dispatch/testing/integration.rb +++ b/actionpack/lib/action_dispatch/testing/integration.rb @@ -338,7 +338,7 @@ module ActionDispatch @integration_session = nil end - %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" -- cgit v1.2.3