Include subgroup issues when searching for group issues using the API
This commit is contained in:
parent
db555cb7cd
commit
b9dfd071ed
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Include subgroup issues when searching for group issues using the API
|
||||
merge_request:
|
||||
author:
|
||||
type: added
|
|
@ -97,7 +97,7 @@ module API
|
|||
get ":id/issues" do
|
||||
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 = {
|
||||
with: Entities::IssueBasic,
|
||||
|
|
|
@ -384,6 +384,30 @@ describe API::Issues do
|
|||
end
|
||||
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
|
||||
get api(base_url, admin)
|
||||
|
||||
|
|
Loading…
Reference in New Issue