Commit fdffe54b authored by Sean McGivern's avatar Sean McGivern

Merge branch 'issue_42443' into 'master'

Include subgroup issues when searching for group issues using the API

Closes #42443

See merge request gitlab-org/gitlab-ce!18068
parents 2faf991f b9dfd071
---
title: Include subgroup issues when searching for group issues using the API
merge_request:
author:
type: added
...@@ -97,7 +97,7 @@ module API ...@@ -97,7 +97,7 @@ module API
get ":id/issues" do get ":id/issues" do
group = find_group!(params[:id]) group = find_group!(params[:id])
issues = paginate(find_issues(group_id: group.id)) issues = paginate(find_issues(group_id: group.id, include_subgroups: true))
options = { options = {
with: Entities::IssueBasic, with: Entities::IssueBasic,
......
...@@ -384,6 +384,30 @@ describe API::Issues do ...@@ -384,6 +384,30 @@ describe API::Issues do
end end
let(:base_url) { "/groups/#{group.id}/issues" } let(:base_url) { "/groups/#{group.id}/issues" }
context 'when group has subgroups', :nested_groups do
let(:subgroup_1) { create(:group, parent: group) }
let(:subgroup_2) { create(:group, parent: subgroup_1) }
let(:subgroup_1_project) { create(:project, namespace: subgroup_1) }
let(:subgroup_2_project) { create(:project, namespace: subgroup_2) }
let!(:issue_1) { create(:issue, project: subgroup_1_project) }
let!(:issue_2) { create(:issue, project: subgroup_2_project) }
before do
group.add_developer(user)
end
it 'also returns subgroups projects issues' do
get api(base_url, user)
issue_ids = json_response.map { |issue| issue['id'] }
expect_paginated_array_response(size: 5)
expect(issue_ids).to include(issue_1.id, issue_2.id)
end
end
it 'returns all group issues (including opened and closed)' do it 'returns all group issues (including opened and closed)' do
get api(base_url, admin) get api(base_url, admin)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment