rails: Just started (3 days ago) getting ActionDispatch::IllegalStateError for controllers rspec test with edge rails
Just started (3 days ago) getting ActionDispatch::IllegalStateError for controllers rspec test with edge rails.
Steps to reproduce
- Given you have a repo: https://github.com/jasnow/testing-app5edge And you run the following: rspec ./spec/controllers/posts_controller_spec.rb:17 Then it will run without errors.
- Now run “bundle upgrade” and you see the following gems were upgraded:
...Rails
- revision: c4cb6862babd2665a65056e205c2a5fd17a5d99d
+ revision: 66ebbc4952f6cfb37d719f63036441ef98149418
...
- rails-dom-testing (2.0.0)
+ rails-dom-testing (2.0.1)
...
- webmock (2.0.3)
+ webmock (2.1.0)
- Now rerun the above rspec test and you get this:
Failure/Error: get :index
ActionDispatch::IllegalStateError:
header already sent
- The total stacktrace is here: https://gist.github.com/jasnow/358925716d2068145790b11e4615cd3e
Expected behavior
Expect the above test to run without the ActionDispatch::IllegalStateError error
Actual behavior
Get error:
Failure/Error: get :index
ActionDispatch::IllegalStateError:
header already sent
The total stacktrace is here: https://gist.github.com/jasnow/358925716d2068145790b11e4615cd3e
System configuration
Rails version: Rails 5.1.0.alpha
- Before: edge Rails: c4cb6862babd2665a65056e205c2a5fd17a5d99d
- After:: edge Rails: 66ebbc4952f6cfb37d719f63036441ef98149418
Ruby version: ruby-2.3.1
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 8
- Comments: 23 (8 by maintainers)
Commits related to this issue
- going back to rc1 due to issue described in https://github.com/rails/rails/issues/25269 — committed to where2help/where2help by haslinger 8 years ago
https://github.com/plataformatec/devise/pull/4169 appears to fix my original problem. The whole community thanks you. - @hamadata and @lucasmazza
I found a workaround for this issue. The tests in devise gem pass with this change.
Devise’s controller helpers seem to be triggering a call to the function
process
which in action_controller/test_case, it sets sent! which is what request.rb is checking to see if the header can be set…Then after this, _process_unauthenticated ends up calling render on ActionController and it sees the request as already sent… Not sure exactly what the change was tho that caused this after some cursory searching…
I encountered the same issue after the upgrade to
rails-5.rc2
from therails-5.rc1
Here you can see the stack trace: https://gist.github.com/dalpo/66824995f6b3509acad444d46fa42da2