-
Notifications
You must be signed in to change notification settings - Fork 21.9k
Support clearing acronyms from inflector #42475
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
Support clearing acronyms from inflector #42475
Conversation
I think this does the same thing as #40790 |
d9baada
to
505a1c6
Compare
@ghiculescu apologies I didn't spot your PR, you noticed this a while back! Happy to close this PR / combine efforts / what ever you prefer – it'd be good to get this fixed 😄 |
3afafcf
to
452e044
Compare
I don't mind which PR gets merged, as long as the issue is fixed :) It looks like we have ended up on the same implementation 😆 Do you want to just check that the tests I added in mine, also work in yours? If you like, you can add them to this PR and I can close mine. |
Thanks @ghiculescu, I moved across two tests from your PR. In particular the extra test which exercises |
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.
Looks good to me. Can you please squash?
Previously calling ActiveSupport::Inflector::Inflections.clear(:acronyms) reset the instance variable to an empty Array, which is not the correct default. The next time an acronym is added a TypeError is thrown.
7d01c62
to
a8ae85a
Compare
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
Summary
Attempting to clear acronyms in the Inflector breaks the implementation. This results in a
TypeError
when attempting to set another acronym:This is because
#clear
sets a new Array for@acronyms
:rails/activesupport/lib/active_support/inflector/inflections.rb
Lines 233 to 234 in 051b0fc
Rather than a Hash (the default initialized value):
rails/activesupport/lib/active_support/inflector/inflections.rb
Lines 78 to 79 in 051b0fc
This PR also extends
ActiveSupport::Inflector::Inflections#clear
/#clear(:all)
to clear acronyms, since this wasn't covered.Other Information
I discovered this issue whilst writing a test for rails/activeresource#361