-
Notifications
You must be signed in to change notification settings - Fork 337
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
Auto plug middleware for simpler installation #431
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! Thank you.
I don't think we would be able to escape having some sort of Rails integration testing... I mean, we want to have a failing test if, for example, Rails 6.1 changes the MiddlewareStack
behavior and Rack::Attack::Railtie
no longer works as expected.
Let me think a bit more about it.
Updated. I dunno how i tested that before locally, but initial implementation was not fully working. We can not use There is a solution: to use
And also there is no way to check if middleware was previously included/removed without using rails' private api, so implementation become a little more complicated than I was expected. Unfortunately, for some unknown reason, can't make new tests pass for rails 4.2, while everything works as expected while manually testing in a local app. |
I suspect this change (rails/rails@d951558) has something to do with the failing tests in 4.2 and passing in 5.0+. |
Thanks for updating and adding tests! |
Maybe, not sure. It's weird to me, that in brand new rails 4.2 app while testing manually in console - everything works, but can't make tests pass. For other versions everything works here and there. I think, this is safe to merge as is. |
I understand that it works on Rails 4.2 for you by testing manually via console as of today, but by not having test coverage we are prone to introducing regressions in any future update or refactor. So I think to be safe we'll want either a working test case or to not make the auto-plug for rails 4.2. |
604f5a1
to
f22b24c
Compare
@grzuy Correct, you are right. Updated to not auto-plug it for rails < 5. |
Nice! Thank you very much for the PR and all the updates! |
@grzuy You probably should configure github's merge button to merge with squash/rebase to make history cleaner for future debuggings. |
Closes #429 and several related issues.
It is hard to test that middleware is actually included by default without generating dummy apps inside spec folder for every tested rails version.
@grzuy maybe you have some ideas how to test this?