-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Move and deprecate trait methods from FactoryBot #1285
Move and deprecate trait methods from FactoryBot #1285
Conversation
4133856
to
0910267
Compare
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.
🎉
spec/support/macros/deprecation.rb
Outdated
@@ -13,6 +13,8 @@ def silence_deprecation(example) | |||
config.include SilenceDeprecation | |||
|
|||
config.around :example, silence_deprecation: true do |example| | |||
silence_deprecation(example) | |||
with_silenced_output do |
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.
I am not a fan of this with_silenced_output
method. This is not longer just silencing the deprecation, it is silencing any output, which would make things hard to debug if anything went wrong.
Instead, I think we can just update the silence_deprecation
method to set FactoryBot::DEPRECATOR.silenced
instead of ActiveSupport::Deprecation.silenced
.
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.
We might also consider renaming FactoryBot::DEPRECATOR
to FactoryBot::Deprecation
so it better matches ActiveSupport::Deprecation
.
0910267
to
c393e7c
Compare
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!
It may make sense to either squash this into 1 single commit, or at least ditch the "Add output suppression macro" commit since you ended up reverting that change.
5c4b9d9
to
d7a2b72
Compare
Why: These are essentially internal methods that should not be publicly available from the base namespace. One thing worth noticing is that the use of this methods internally was almost exclusively in the `syntax/default` except for one use on the `factory_bot/definition`. Also the deprecation silencing module was referring to the singleton instance of the ```ActiveRecord::Deprecation``` class and not to the new deprecation instance that was being used in the ```FactoryBot``` module. This PR: - Moves the `trait_by_name` and `register_trait` into the `FactoryBot::Internal` module - Deprecates uses of `trait_by_name`, `register_trait` and `traits` from the `FactoryBot` module. - Rename DEPRECATOR => Deprecation This is one of the steps towards fixing [this issue](#1281)
d7a2b72
to
b74acf4
Compare
Why: Another run of internal methods that should not be publicly available from the base namespace. This time the sequence involving methods were moved. It's worth noticing that the ```Internal``` class is getting crowded. Maybe we can start name-spacing the internal groups into modules under ```internal/sequence.rb``` ```internal/trait.rb``` and so on. Thoughts? This PR: - Moves the ```register_sequence```, ```sequence_by_name```, ```sequences``` and ```rewind_sequences``` to the ```FactoryBot::Internal``` module. - Deprecates uses of ```register_sequence```, ```sequence_by_name```, ```sequences``` and ```rewind_sequences``` from the ```FactoryBot``` module. This is one of the steps towards fixing [this issue](#1285 (comment))
Why: Another run of internal methods that should not be publicly available from the base namespace. This time the sequence involving methods were moved. It's worth noticing that the ```Internal``` class is getting crowded. Maybe we can start name-spacing the internal groups into modules under ```internal/sequence.rb``` ```internal/trait.rb``` and so on. Thoughts? This PR: - Moves the ```register_sequence```, ```sequence_by_name```, ```sequences``` and ```rewind_sequences``` to the ```FactoryBot::Internal``` module. - Deprecates uses of ```register_sequence```, ```sequence_by_name```, ```sequences``` and ```rewind_sequences``` from the ```FactoryBot``` module. This is one of the steps towards fixing [this issue](#1285 (comment))
Why: Another run of internal methods that should not be publicly available from the base namespace. This time the sequence involving methods were moved. It's worth noticing that the ```Internal``` class is getting crowded. Maybe we can start name-spacing the internal groups into modules under ```internal/sequence.rb``` ```internal/trait.rb``` and so on. Thoughts? This PR: - Moves the ```register_sequence```, ```sequence_by_name```, ```sequences``` and ```rewind_sequences``` to the ```FactoryBot::Internal``` module. - Deprecates uses of ```sequence_by_name```, and ```sequences``` from the ```FactoryBot``` module. This is one of the steps towards fixing [this issue](#1285 (comment))
Why: Another run of internal methods that should not be publicly available from the base namespace. This time the sequence involving methods were moved. It's worth noticing that the ```Internal``` class is getting crowded. Maybe we can start name-spacing the internal groups into modules under ```internal/sequence.rb``` ```internal/trait.rb``` and so on. Thoughts? This PR: - Moves the ```register_sequence```, ```sequence_by_name```, ```sequences``` and ```rewind_sequences``` to the ```FactoryBot::Internal``` module. - Deprecates uses of ```sequence_by_name```, and ```sequences``` from the ```FactoryBot``` module. This is one of the steps towards fixing [this issue](#1285 (comment))
Why: Another run of internal methods that should not be publicly available from the base namespace. This time the sequence involving methods were moved. It's worth noticing that the ```Internal``` class is getting crowded. Maybe we can start name-spacing the internal groups into modules under ```internal/sequence.rb``` ```internal/trait.rb``` and so on. Thoughts? This PR: - Moves the ```register_sequence```, ```sequence_by_name```, ```sequences``` and ```rewind_sequences``` to the ```FactoryBot::Internal``` module. - Deprecates uses of ```sequence_by_name```, and ```sequences``` from the ```FactoryBot``` module. - Refactor rewind sequences test to use spies This is one of the steps towards fixing [this issue](#1285 (comment))
Why: Another run of internal methods that should not be publicly available from the base namespace. This time the sequence involving methods were moved. It's worth noticing that the ```Internal``` class is getting crowded. Maybe we can start name-spacing the internal groups into modules under ```internal/sequence.rb``` ```internal/trait.rb``` and so on. Thoughts? This PR: - Moves the ```register_sequence```, ```sequence_by_name```, ```sequences``` and ```rewind_sequences``` to the ```FactoryBot::Internal``` module. - Deprecates uses of ```sequence_by_name```, and ```sequences``` from the ```FactoryBot``` module. - Refactor rewind sequences test to use spies This is one of the steps towards fixing [this issue](#1285 (comment))
Why: Another run of internal methods that should not be publicly available from the base namespace. This time the sequence involving methods were moved. It's worth noticing that the ```Internal``` class is getting crowded. Maybe we can start name-spacing the internal groups into modules under ```internal/sequence.rb``` ```internal/trait.rb``` and so on. Thoughts? This PR: - Moves the ```register_sequence```, ```sequence_by_name```, ```sequences``` and ```rewind_sequences``` to the ```FactoryBot::Internal``` module. - Deprecates uses of ```sequence_by_name```, and ```sequences``` from the ```FactoryBot``` module. This is one of the steps towards fixing [this issue](#1285 (comment))
Why: Another run of internal methods that should not be publicly available from the base namespace. This time the sequence involving methods were moved. It's worth noticing that the ```Internal``` class is getting crowded. Maybe we can start name-spacing the internal groups into modules under ```internal/sequence.rb``` ```internal/trait.rb``` and so on. Thoughts? This PR: - Moves the ```register_sequence```, ```sequence_by_name```, ```sequences``` and ```rewind_sequences``` to the ```FactoryBot::Internal``` module. - Deprecates uses of ```sequence_by_name```, and ```sequences``` from the ```FactoryBot``` module. - Refactor rewind sequences test to use spies This is one of the steps towards fixing [this issue](thoughtbot/factory_bot#1285 (comment))
Why: Another run of internal methods that should not be publicly available from the base namespace. This time the sequence involving methods were moved. It's worth noticing that the ```Internal``` class is getting crowded. Maybe we can start name-spacing the internal groups into modules under ```internal/sequence.rb``` ```internal/trait.rb``` and so on. Thoughts? This PR: - Moves the ```register_sequence```, ```sequence_by_name```, ```sequences``` and ```rewind_sequences``` to the ```FactoryBot::Internal``` module. - Deprecates uses of ```sequence_by_name```, and ```sequences``` from the ```FactoryBot``` module. - Refactor rewind sequences test to use spies This is one of the steps towards fixing [this issue](thoughtbot/factory_bot#1285 (comment))
Why:
These are essentially internal methods that should not be publicly
available from the base namespace.
One thing worth noticing is that the use of these methods internally was
almost exclusively in the
syntax/default
except for one use on thefactory_bot/definition
.Also, the deprecation silencing module was referring to the singleton
an instance of the
ActiveRecord:: Deprecation
class and not to the newdeprecation instance that was being used in the
FactoryBot
module.This PR:
trait_by_name
andregister_trait
into theFactoryBot::Internal
moduletrait_by_name
,register_trait
andtraits
fromthe
FactoryBot
module.This is one of the steps towards fixing this
issue