summaryrefslogtreecommitdiff
path: root/spec/requests/groups
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-25 00:06:14 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-25 00:06:14 +0000
commit6d43720a1a86ccca9618417a6d0415e7d522fa49 (patch)
treeceab63f6374252b8afe4913b949bae39a027366f /spec/requests/groups
parent46bfa73d93786bc2a832be7e42e2119712a0bafb (diff)
downloadgitlab-ce-6d43720a1a86ccca9618417a6d0415e7d522fa49.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests/groups')
-rw-r--r--spec/requests/groups/registry/repositories_controller_spec.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/requests/groups/registry/repositories_controller_spec.rb b/spec/requests/groups/registry/repositories_controller_spec.rb
new file mode 100644
index 00000000000..35fdeaab604
--- /dev/null
+++ b/spec/requests/groups/registry/repositories_controller_spec.rb
@@ -0,0 +1,36 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Groups::Registry::RepositoriesController do
+ let_it_be(:group, reload: true) { create(:group) }
+ let_it_be(:user) { create(:user) }
+
+ before do
+ stub_container_registry_config(enabled: true)
+
+ group.add_reporter(user)
+ login_as(user)
+ end
+
+ describe 'GET groups/:group_id/-/container_registries.json' do
+ it 'avoids N+1 queries' do
+ project = create(:project, group: group)
+ create(:container_repository, project: project)
+ endpoint = group_container_registries_path(group, format: :json)
+
+ control_count = ActiveRecord::QueryRecorder.new(skip_cached: false) { get(endpoint) }.count
+
+ create_list(:project, 2, group: group).each do |project|
+ create_list(:container_repository, 2, project: project)
+ end
+
+ expect { get(endpoint) }.not_to exceed_all_query_limit(control_count)
+
+ # sanity check that response is 200
+ expect(response).to have_http_status(200)
+ repositories = json_response
+ expect(repositories.count).to eq(5)
+ end
+ end
+end