diff options
author | Felipe Artur <felipefac@gmail.com> | 2018-03-28 23:39:12 +0300 |
---|---|---|
committer | Felipe Artur <felipefac@gmail.com> | 2018-04-05 23:19:52 +0300 |
commit | b9dfd071ed7260e9a3f470317011bcdcfedd61ed (patch) | |
tree | 83dcef4494abf9acd9c67345b004a769b7acecf9 | |
parent | db555cb7cd5390381bf517c3b73b2aa0a27e5375 (diff) |
Include subgroup issues when searching for group issues using the API
-rw-r--r-- | changelogs/unreleased/issue_42443.yml | 5 | ||||
-rw-r--r-- | lib/api/issues.rb | 2 | ||||
-rw-r--r-- | spec/requests/api/issues_spec.rb | 24 |
3 files changed, 30 insertions, 1 deletions
diff --git a/changelogs/unreleased/issue_42443.yml b/changelogs/unreleased/issue_42443.yml new file mode 100644 index 00000000000..954fbd98a4b --- /dev/null +++ b/changelogs/unreleased/issue_42443.yml @@ -0,0 +1,5 @@ +--- +title: Include subgroup issues when searching for group issues using the API +merge_request: +author: +type: added diff --git a/lib/api/issues.rb b/lib/api/issues.rb index f74b3b26802..88e7f46c92c 100644 --- a/lib/api/issues.rb +++ b/lib/api/issues.rb @@ -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, diff --git a/spec/requests/api/issues_spec.rb b/spec/requests/api/issues_spec.rb index 6614e8cea43..90f9c4ad214 100644 --- a/spec/requests/api/issues_spec.rb +++ b/spec/requests/api/issues_spec.rb @@ -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) |