Commit 6f1f6577 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'pl-doc-testing-factory-assoc' into 'master'

Mention explicit/implicit association set up in testing guide docs

See merge request gitlab-org/gitlab!44447
parents 4282739a 53f9c447
...@@ -895,6 +895,10 @@ GitLab uses [factory_bot](https://github.com/thoughtbot/factory_bot) as a test f ...@@ -895,6 +895,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