diff options
author | Edouard CHIN <edouard.chin@shopify.com> | 2017-06-23 15:41:35 -0400 |
---|---|---|
committer | Edouard CHIN <edouard.chin@shopify.com> | 2017-06-26 13:42:56 -0400 |
commit | 2508c7de267794781efb6d5f61d293c650d3d6e5 (patch) | |
tree | c91c86615b44a671f1a8b44d60072ecccc7760b9 /actionpack/test/controller | |
parent | 98d12f1ef31014287c897fc60df4e1af70781ca3 (diff) | |
download | rails-2508c7de267794781efb6d5f61d293c650d3d6e5.tar.gz rails-2508c7de267794781efb6d5f61d293c650d3d6e5.tar.bz2 rails-2508c7de267794781efb6d5f61d293c650d3d6e5.zip |
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
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r-- | actionpack/test/controller/integration_test.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb index 72163ccd5e..cb282d4330 100644 --- a/actionpack/test/controller/integration_test.rb +++ b/actionpack/test/controller/integration_test.rb @@ -335,6 +335,18 @@ class IntegrationProcessTest < ActionDispatch::IntegrationTest end end + def test_redirect_reset_html_document + with_test_route_set do + get "/redirect" + previous_html_document = html_document + + follow_redirect! + + assert_response :ok + refute_same previous_html_document, html_document + end + end + def test_xml_http_request_get with_test_route_set do get "/get", xhr: true |