Commit 53f9c447 authored by Peter Leitzen's avatar Peter Leitzen

Mention explicit/implicit association set up in testing guide docs

parent 6cf719ee
...@@ -890,6 +890,10 @@ GitLab uses [factory_bot](https://github.com/thoughtbot/factory_bot) as a test f ...@@ -890,6 +890,10 @@ GitLab uses [factory_bot](https://github.com/thoughtbot/factory_bot) as a test f
resulting record to pass validation. resulting record to pass validation.
- When instantiating from a factory, don't supply attributes that aren't - When instantiating from a factory, don't supply attributes that aren't
required by the test. required by the test.
- Prefer [implicit](https://github.com/thoughtbot/factory_bot/blob/master/GETTING_STARTED.md#implicit-definition)
or [explicit](https://github.com/thoughtbot/factory_bot/blob/master/GETTING_STARTED.md#explicit-definition)
association definitions instead of using `create` / `build` for association setup.
See [issue #262624](https://gitlab.com/gitlab-org/gitlab/-/issues/262624) for further context.
- Factories don't have to be limited to `ActiveRecord` objects. - Factories don't have to be limited to `ActiveRecord` objects.
[See example](https://gitlab.com/gitlab-org/gitlab-foss/commit/0b8cefd3b2385a21cfed779bd659978c0402766d). [See example](https://gitlab.com/gitlab-org/gitlab-foss/commit/0b8cefd3b2385a21cfed779bd659978c0402766d).
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment