debian-mirror-gitlab/spec/requests/groups/registry/repositories_controller_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

38 lines
1.2 KiB
Ruby
Raw Permalink Normal View History

2019-12-26 22:10:19 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-03-04 22:38:38 +05:30
RSpec.describe Groups::Registry::RepositoriesController, feature_category: :container_registry do
2019-12-26 22:10:19 +05:30
let_it_be(:group, reload: true) { create(:group) }
let_it_be(:user) { create(:user) }
before do
stub_container_registry_config(enabled: true)
2020-06-23 00:09:42 +05:30
stub_container_registry_tags(repository: :any, tags: [])
2021-11-18 22:05:49 +05:30
stub_container_registry_info
2019-12-26 22:10:19 +05:30
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
2020-04-08 14:13:33 +05:30
expect(response).to have_gitlab_http_status(:ok)
2019-12-26 22:10:19 +05:30
repositories = json_response
expect(repositories.count).to eq(5)
end
end
end