Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix overriding ActionController::Live with test_behaviour when not test mode. #183

Closed
wants to merge 1 commit into from

Conversation

gurix
Copy link
Contributor

@gurix gurix commented Mar 22, 2018

Including ActionController::TestCase::Behavior overrides ActionController::Live#new_controller_thread as discussed on rails/rails#31200. This issue also affects any production mode as the include is not done just in test mode.

This pull request separates production code from test code by query the environment. I am not satisfied by this solution. In the future we should think about separating even more by monkey patching in tests only.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 99.353% when pulling 7db6ba8 on gurix:master into 6279fb1 on enriclluelles:master.

4 similar comments
@coveralls
Copy link

Coverage Status

Coverage remained the same at 99.353% when pulling 7db6ba8 on gurix:master into 6279fb1 on enriclluelles:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 99.353% when pulling 7db6ba8 on gurix:master into 6279fb1 on enriclluelles:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 99.353% when pulling 7db6ba8 on gurix:master into 6279fb1 on enriclluelles:master.

@coveralls
Copy link

coveralls commented Mar 22, 2018

Coverage Status

Coverage remained the same at 99.353% when pulling 7db6ba8 on gurix:master into 6279fb1 on enriclluelles:master.

@tagliala
Copy link
Collaborator

tagliala commented Apr 6, 2018

@gurix sorry for the very late reply

If this is the best solution at the moment, we will go for it

Please give me a couple of days

@tagliala tagliala added the bug label Apr 6, 2018
@tagliala
Copy link
Collaborator

tagliala commented Apr 7, 2018

@gurix a couple of questions:

  1. Any chance of adding a failing test case?
  2. How does rails conditionally load TestCase in test environment?

I can see that in production environment ActionController::TestCase is loaded:

$ rails c production
Running via Spring preloader in process 10786
Loading production environment (Rails 5.2.0.rc2)
2.5.0 :001 > defined?(ActionController::TestCase)
 => "constant" 

@gurix
Copy link
Contributor Author

gurix commented Apr 9, 2018

@tagliala Thanks for your response.

  1. I have no Idea how to implement a test for that because rails itself having this issue when testing. So every test including ActionController::Live hangs after 10 responses. And testing if it works when not in the test environment does not make any sense as we are by definition in it.

  2. Yes, but i guess ActionController::TestCase is loaded somehow before ActionController::Live which then overrides what's in ActionController::TestCase. And what you are doing is load it again and override it with ActionController::TestCase.

As I wrote, i am not very happy with this solution as it is somehow a rails problem done by @tenderlove two years ago. But it is the best fix for the moment. I also wrote him but had no answer til now.

@tagliala
Copy link
Collaborator

tagliala commented Apr 9, 2018

@gurix thanks

I'm not going to merge this PR because I was working on another branch and I've cherry-picked your commit

@tagliala tagliala closed this Apr 9, 2018
@tagliala tagliala added this to the 5.6.1 milestone Apr 9, 2018
@tagliala
Copy link
Collaborator

tagliala commented Apr 9, 2018

5.6.1 released

Don't worry about the Travis.CI failure, it is because of a rails 5.2 issue with Ruby 2.2.10

@gurix
Copy link
Contributor Author

gurix commented Apr 11, 2018

Cool, I just updated my broken App with version 5.6.2 and now everything is working fine. Now I can bump my production site to rails 5.1. 🎉💃🏻Thanks for your support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants