diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-18 12:45:46 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-18 12:45:46 +0300 |
commit | a7b3560714b4d9cc4ab32dffcd1f74a284b93580 (patch) | |
tree | 7452bd5c3545c2fa67a28aa013835fb4fa071baf /spec/requests/api/groups_spec.rb | |
parent | ee9173579ae56a3dbfe5afe9f9410c65bb327ca7 (diff) |
Add latest changes from gitlab-org/gitlab@14-8-stable-eev14.8.0-rc42
Diffstat (limited to 'spec/requests/api/groups_spec.rb')
-rw-r--r-- | spec/requests/api/groups_spec.rb | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb index 88c004345fc..7de3567dcdd 100644 --- a/spec/requests/api/groups_spec.rb +++ b/spec/requests/api/groups_spec.rb @@ -1163,17 +1163,33 @@ RSpec.describe API::Groups do expect(json_response.length).to eq(3) end - it "returns projects including those in subgroups" do - subgroup = create(:group, parent: group1) - create(:project, group: subgroup) - create(:project, group: subgroup) + context 'when include_subgroups is true' do + it "returns projects including those in subgroups" do + subgroup = create(:group, parent: group1) + create(:project, group: subgroup) + create(:project, group: subgroup) - get api("/groups/#{group1.id}/projects", user1), params: { include_subgroups: true } + get api("/groups/#{group1.id}/projects", user1), params: { include_subgroups: true } - expect(response).to have_gitlab_http_status(:ok) - expect(response).to include_pagination_headers - expect(json_response).to be_an(Array) - expect(json_response.length).to eq(5) + expect(response).to have_gitlab_http_status(:ok) + expect(response).to include_pagination_headers + expect(json_response).to be_an(Array) + expect(json_response.length).to eq(5) + end + end + + context 'when include_ancestor_groups is true' do + it 'returns ancestors groups projects' do + subgroup = create(:group, parent: group1) + subgroup_project = create(:project, group: subgroup) + + get api("/groups/#{subgroup.id}/projects", user1), params: { include_ancestor_groups: true } + + records = Gitlab::Json.parse(response.body) + expect(response).to have_gitlab_http_status(:ok) + expect(response).to include_pagination_headers + expect(records.map { |r| r['id'] }).to match_array([project1.id, project3.id, subgroup_project.id, archived_project.id]) + end end it "does not return a non existing group" do |