Skip to content

Conversation

@btoews
Copy link
Contributor

@btoews btoews commented Nov 25, 2015

I ran into a very-hard-to-diagnose bug when trying to write tests for #22275. request.env['PATH_INFO'] is not reset between test requests. This causes request.fullpath (and probably other methods) to return incorrect values on subsequent requests.

0456caf introduces a test case demonstrating this bug. request.env['PATH_INFO'] was /test_case_test/test/path_one for both requests.

6cc3534 fixes this bug by deleting PATH_INFO from the request env between requests.

I'm not 💯 on this fix because it breaks any tests that explicitly set @request.env['PATH_INFO'] (example).

/cc @jeremy because he is reviewing #22275

@rails-bot
Copy link

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @rafaelfranca (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@btoews btoews mentioned this pull request Nov 25, 2015
@pixeltrix
Copy link
Contributor

@mastahyeti yes, deleting PATH_INFO before or after a call to process can break tests as I outlined in #13851. Since controller tests haven't historically been processed by the full stack people have often configured environment variables to make things work and this makes them very susceptible to failing when we tinker with this behaviour.

Given that we're suggesting people move away from controller tests to integration tests because we've made them faster than controller tests in Rails 5 I'm not sure what the best thing to do here is. One option is to remove support for setting PATH_INFO in controller tests and always use the generated path, however we'd need to go through a deprecation phase for that.

@btoews
Copy link
Contributor Author

btoews commented Nov 25, 2015

Oh, damn. I wish I found that issue earlier last night 😄.

@btoews
Copy link
Contributor Author

btoews commented Nov 30, 2015

I'm going to close this, as it isn't a great solution to the problem and the problem is well documented in #13851.

@btoews btoews closed this Nov 30, 2015
@btoews btoews deleted the ac_test_path_fix branch November 30, 2015 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants