diff options
author | Thong Kuah <tkuah@gitlab.com> | 2019-08-18 08:57:24 +0000 |
---|---|---|
committer | Thong Kuah <tkuah@gitlab.com> | 2019-08-20 23:12:48 +1200 |
commit | 3b7df66eef935046363c39d835b0a34d85b51584 (patch) | |
tree | d44001fe97ade3a9ef830e3ed36b642e6f87fdc6 /doc/development/query_recorder.md | |
parent | 1068483f7260e5866c7d54f1f09b716dbf463c80 (diff) | |
download | gitlab-ce-3b7df66eef935046363c39d835b0a34d85b51584.tar.gz |
Require request specs when testing N+1 for controllers
Diffstat (limited to 'doc/development/query_recorder.md')
-rw-r--r-- | doc/development/query_recorder.md | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/doc/development/query_recorder.md b/doc/development/query_recorder.md index a6b60149ea4..3787e2ef187 100644 --- a/doc/development/query_recorder.md +++ b/doc/development/query_recorder.md @@ -36,6 +36,13 @@ it "avoids N+1 database queries" do end ``` +## Use request specs instead of controller specs + +Use a [request spec](https://gitlab.com/gitlab-org/gitlab-ce/tree/master/spec/requests) when writing a N+1 test on the controller level. + +Controller specs should not be used to write N+1 tests as the controller is only initialized once per example. +This could lead to false successes where subsequent "requests" could have queries reduced (e.g. because of memoization). + ## Finding the source of the query It may be useful to identify the source of the queries by looking at the call backtrace. |