You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 22, 2021. It is now read-only.
I just upgraded to Rails 5.1.2 (from 5.0.1) and discovered that it's no longer possible to pass in headers: {} into get/patch/post/etc request test helpers. So the example in the README:
get secured_resources_url, headers: authenticated_header
no longer works. I did a bit of digging and found a couple of solutions here. I ended up reimplementing my tests like this:
request.headers.merge!('HTTP_AUTHORIZATION' => retrieve_access_token(user))
get path, params: params
I'm happy to submit a PR if you think that's the best way to go. 🙂
The text was updated successfully, but these errors were encountered:
Sorry for the slow update! It does appear to be a difference with rspec-rails, specifically with controller tests.
This doesn't work as controller tests include ActionController::TestCase::Behavior, which doesn't handle headers: in requests. Request specs work fine as they are including ActionDispatch::IntegrationTest::Behavior similar to your tests.
I'm happy to add an example rspec controller test in the README if you'd like?
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I just upgraded to Rails 5.1.2 (from 5.0.1) and discovered that it's no longer possible to pass in
headers: {}
into get/patch/post/etc request test helpers. So the example in the README:no longer works. I did a bit of digging and found a couple of solutions here. I ended up reimplementing my tests like this:
I'm happy to submit a PR if you think that's the best way to go. 🙂
The text was updated successfully, but these errors were encountered: