diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
commit | 0ea3fcec397b69815975647f5e2aa5fe944a8486 (patch) | |
tree | 7979381b89d26011bcf9bdc989a40fcc2f1ed4ff /spec/models/preloaders/user_max_access_level_in_projects_preloader_spec.rb | |
parent | 72123183a20411a36d607d70b12d57c484394c8e (diff) |
Add latest changes from gitlab-org/gitlab@15-1-stable-eev15.1.0-rc42
Diffstat (limited to 'spec/models/preloaders/user_max_access_level_in_projects_preloader_spec.rb')
-rw-r--r-- | spec/models/preloaders/user_max_access_level_in_projects_preloader_spec.rb | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/spec/models/preloaders/user_max_access_level_in_projects_preloader_spec.rb b/spec/models/preloaders/user_max_access_level_in_projects_preloader_spec.rb index eefe5bfc6c4..7d4268f74e9 100644 --- a/spec/models/preloaders/user_max_access_level_in_projects_preloader_spec.rb +++ b/spec/models/preloaders/user_max_access_level_in_projects_preloader_spec.rb @@ -7,8 +7,10 @@ RSpec.describe Preloaders::UserMaxAccessLevelInProjectsPreloader do let_it_be(:project_1) { create(:project) } let_it_be(:project_2) { create(:project) } let_it_be(:project_3) { create(:project) } + let_it_be(:project_4) { create(:project) } + let_it_be(:project_5) { create(:project) } - let(:projects) { [project_1, project_2, project_3] } + let(:projects) { [project_1, project_2, project_3, project_4, project_5] } let(:query) { projects.each { |project| user.can?(:read_project, project) } } before do @@ -17,8 +19,11 @@ RSpec.describe Preloaders::UserMaxAccessLevelInProjectsPreloader do end context 'without preloader' do - it 'runs N queries' do - expect { query }.to make_queries(projects.size) + it 'runs some queries' do + # we have an existing N+1, one for each project for which user is not a member + # in this spec, project_3, project_4, project_5 + # https://gitlab.com/gitlab-org/gitlab/-/issues/362890 + expect { query }.to make_queries(projects.size + 3) end end @@ -34,7 +39,7 @@ RSpec.describe Preloaders::UserMaxAccessLevelInProjectsPreloader do end context 'when projects is an array of IDs' do - let(:projects_arg) { [project_1.id, project_2.id, project_3.id] } + let(:projects_arg) { projects.map(&:id) } it 'avoids N+1 queries' do expect { query }.not_to make_queries |