Commit bfa25b35 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch '28352-group-issues-api-searches-archived-projects' into 'master'

Add non_archived param to group issues API endpoint

Closes #28352

See merge request gitlab-org/gitlab!23785
parents 0f29bc50 74a0f254
---
title: Add non_archived param to issues API endpoint to filter issues from archived projects
merge_request: 23785
author:
type: added
......@@ -222,6 +222,7 @@ GET /groups/:id/issues?confidential=true
| `updated_before` | datetime | no | Return issues updated on or before the given time |
| `confidential` | Boolean | no | Filter confidential or public issues. |
| `not` | Hash | no | Return issues that do not match the parameters supplied. Accepts: `labels`, `milestone`, `author_id`, `author_username`, `assignee_id`, `assignee_username`, `my_reaction_emoji`, `search`, `in` |
| `non_archived` | Boolean | no | Return issues from non archived projects. Default is true. _(Introduced in [GitLab 12.8](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/23785))_ |
```shell
curl --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/groups/4/issues
......
......@@ -120,6 +120,7 @@ module API
end
params do
use :issues_params
optional :non_archived, type: Boolean, desc: 'Return issues from non archived projects', default: true
end
get ":id/issues" do
issues = paginate(find_issues(group_id: user_group.id, include_subgroups: true))
......
......@@ -778,6 +778,32 @@ describe API::Issues do
expect(json_response["error"]).to include("mutually exclusive")
end
end
context 'filtering by non_archived' do
let_it_be(:group1) { create(:group) }
let_it_be(:archived_project) { create(:project, :archived, namespace: group1) }
let_it_be(:active_project) { create(:project, namespace: group1) }
let_it_be(:issue1) { create(:issue, project: active_project) }
let_it_be(:issue2) { create(:issue, project: active_project) }
let_it_be(:issue3) { create(:issue, project: archived_project) }
before do
archived_project.add_developer(user)
active_project.add_developer(user)
end
it 'returns issues from non archived projects only by default' do
get api("/groups/#{group1.id}/issues", user), params: { scope: 'all' }
expect_response_contain_exactly(issue2, issue1)
end
it 'returns issues from archived and non archived projects when non_archived is false' do
get api("/groups/#{group1.id}/issues", user), params: { non_archived: false, scope: 'all' }
expect_response_contain_exactly(issue1, issue2, issue3)
end
end
end
context "when returns issue merge_requests_count for different access levels" do
......@@ -862,4 +888,9 @@ describe API::Issues do
include_examples 'time tracking endpoints', 'issue'
end
def expect_response_contain_exactly(*items)
expect(json_response.length).to eq(items.size)
expect(json_response.map { |element| element['id'] }).to contain_exactly(*items.map(&:id))
end
end
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