1
0
Fork 0
mirror of https://github.com/thoughtbot/factory_bot.git synced 2022-11-09 11:43:51 -05:00
thoughtbot--factory_bot/spec
Daniel Colson 7cfa233775 Remove code for registering callbacks
Before this commit, factory_bot registered default callbacks in a global
registry, and offered a `register_callback` method for registering any
custom callbacks (which would be fired within custom strategies).

The idea here seems to have been that we could check against this global
registry and then raise an error when referring to a callback that was
not registered.

However, nobody ever saw this error because we have always had the line:
`FactoryBot::Internal.register_callback(name)`, which registers
callbacks on the fly whenever they are referred to. (I noticed this when
a [change to default callbacks] accidentally duplicated `after_create`
instead of including `before_create`, and we didn't get any tests
failures.)

We have two options here:

1. Preserve the existing behavior by deleting all the callback
registration code. (That is what this commit does)

2. Change to the code try and capture what I assume was the original
intention. This would be a breaking change, so we would want to
introduce it in a major release. (See #1379)

I prefer preserving the existing behavior because we haven't seen any
issues around this, and making a breaking change for this doesn't seem
worthwhile.

[change to default callbacks]: f82e40c8c5 (diff-c6d30be672f880311a7df0820dc4fb21R12-R14)
2020-05-29 14:52:23 -04:00
..
acceptance Add functionality for enum traits (#1380) 2020-05-01 17:50:51 -04:00
factory_bot Remove code for registering callbacks 2020-05-29 14:52:23 -04:00
support Run automatic cop fixes 2020-01-17 14:43:34 -05:00
factory_bot_spec.rb Prepare for factory_bot 6 2020-05-01 17:43:10 -04:00
spec_helper.rb Adjust use_parent_strategy safely in specs 2019-08-12 18:54:53 +01:00