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

Move and deprecate trait methods from FactoryBot #1285

Merged
merged 1 commit into from
Apr 26, 2019

Conversation

aledustet
Copy link
Contributor

@aledustet aledustet commented Apr 19, 2019

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 the
factory_bot/definition.
Also, the deprecation silencing module was referring to the singleton
an 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

spec/support/macros/output.rb Outdated Show resolved Hide resolved
spec/support/macros/output.rb Outdated Show resolved Hide resolved
@aledustet aledustet force-pushed the chore/move-trait-methods-to-factory-bot-internal branch from 4133856 to 0910267 Compare April 19, 2019 20:25
Copy link
Collaborator

@composerinteralia composerinteralia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@@ -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
Copy link
Collaborator

@composerinteralia composerinteralia Apr 21, 2019

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.

Copy link
Collaborator

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.

@aledustet aledustet force-pushed the chore/move-trait-methods-to-factory-bot-internal branch from 0910267 to c393e7c Compare April 26, 2019 18:01
Copy link
Collaborator

@composerinteralia composerinteralia left a 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.

@aledustet aledustet force-pushed the chore/move-trait-methods-to-factory-bot-internal branch from 5c4b9d9 to d7a2b72 Compare April 26, 2019 18:45
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)
@aledustet aledustet force-pushed the chore/move-trait-methods-to-factory-bot-internal branch from d7a2b72 to b74acf4 Compare April 26, 2019 18:54
aledustet added a commit that referenced this pull request Apr 26, 2019
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))
@aledustet aledustet merged commit 99ac024 into master Apr 26, 2019
@aledustet aledustet deleted the chore/move-trait-methods-to-factory-bot-internal branch April 26, 2019 20:03
aledustet added a commit that referenced this pull request Apr 26, 2019
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))
aledustet added a commit that referenced this pull request May 3, 2019
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))
aledustet added a commit that referenced this pull request May 24, 2019
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))
aledustet added a commit that referenced this pull request Jun 4, 2019
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))
aledustet added a commit that referenced this pull request Jun 4, 2019
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))
aledustet added a commit that referenced this pull request Jun 4, 2019
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))
connorchris831 pushed a commit to connorchris831/factory_bot that referenced this pull request Dec 13, 2022
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))
SriHarshaxi pushed a commit to SriHarshaxi/factory_bot that referenced this pull request Mar 17, 2023
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))
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.

None yet

3 participants