Consider disallowing N+1 query tests in controller specs

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

  • Close this issue

Doing N+1 query tests in controller specs can be problematic as seen in https://gitlab.com/gitlab-org/gitlab-ce/issues/64116

From https://gitlab.com/gitlab-org/gitlab-ce/issues/64116#note_188387768: It is also better to do these kinds of tests in request / feature specs as it is more representative of behavior in production. For instance, I think ActiveRecord::QueryCache is not used in controller specs because it doesn't go through Rack middleware.

I'm not sure how we would enforce this though. Rubocop rule preventing use of QueryRecorder perhaps?

Edited Sep 28, 2025 by 🤖 GitLab Bot 🤖
Assignee Loading
Time tracking Loading