diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-07 18:07:50 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-07 18:07:50 +0000 |
commit | ec169c6384b44291551eb7998b4f7f1102a8af07 (patch) | |
tree | db35206559e536f354e53d71365054062f43b7fc /spec/requests/api/groups_spec.rb | |
parent | f3597fc9f048f07e717ac4cb743a083b219f6258 (diff) | |
download | gitlab-ce-ec169c6384b44291551eb7998b4f7f1102a8af07.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests/api/groups_spec.rb')
-rw-r--r-- | spec/requests/api/groups_spec.rb | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb index cb97398805a..c7b35d6f50d 100644 --- a/spec/requests/api/groups_spec.rb +++ b/spec/requests/api/groups_spec.rb @@ -488,6 +488,51 @@ describe API::Groups do expect(response).to have_gitlab_http_status(404) end end + + context 'limiting the number of projects and shared_projects in the response' do + let(:limit) { 1 } + + before do + stub_const("GroupProjectsFinder::DEFAULT_PROJECTS_LIMIT", limit) + + # creates 3 public projects + create_list(:project, 3, :public, namespace: group1) + + # creates 3 shared projects + public_group = create(:group, :public) + projects_to_be_shared = create_list(:project, 3, :public, namespace: public_group) + + projects_to_be_shared.each do |project| + create(:project_group_link, project: project, group: group1) + end + end + + context 'when limiting feature is enabled' do + before do + stub_feature_flags(limit_projects_in_groups_api: true) + end + + it 'limits projects and shared_projects' do + get api("/groups/#{group1.id}") + + expect(json_response['projects'].count).to eq(limit) + expect(json_response['shared_projects'].count).to eq(limit) + end + end + + context 'when limiting feature is not enabled' do + before do + stub_feature_flags(limit_projects_in_groups_api: false) + end + + it 'does not limit projects and shared_projects' do + get api("/groups/#{group1.id}") + + expect(json_response['projects'].count).to eq(3) + expect(json_response['shared_projects'].count).to eq(3) + end + end + end end describe 'PUT /groups/:id' do |