Commit cb898c49 authored by Eugenia Grieff's avatar Eugenia Grieff

Add non_archived param for merge requests api

The param default value is true, returning
merge requests from non archived projects only.
parent 37e32369
---
title: Add non_archived param to group merge requests API endpoint to filter MRs from non archived projects
merge_request: 23809
author:
type: added
......@@ -396,7 +396,8 @@ Parameters:
| `my_reaction_emoji` | string | no | Return merge requests reacted by the authenticated user by the given `emoji`. `None` returns issues not given a reaction. `Any` returns issues given at least one reaction. _([Introduced][ce-14016] in GitLab 10.0)_ |
| `source_branch` | string | no | Return merge requests with the given source branch |
| `target_branch` | string | no | Return merge requests with the given target branch |
| `search` | string | no | Search merge requests against their `title` and `description` |
| `search` | string | no | Search merge requests against their `title` and `description` |
| `non_archived` | Boolean | no | Return merge requests from non archived projects only. Default is true. _(Introduced in [GitLab 12.8](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/23809))_ |
```json
[
......
......@@ -141,6 +141,8 @@ module API
end
params do
use :merge_requests_params
optional :non_archived, type: Boolean, desc: 'Return merge requests from non archived projects',
default: true
end
get ":id/merge_requests" do
merge_requests = find_merge_requests(group_id: user_group.id, include_subgroups: true)
......
......@@ -807,6 +807,38 @@ describe API::MergeRequests do
end
end
end
context 'with archived projects' do
let(:project2) { create(:project, :public, :archived, namespace: group) }
let!(:merge_request_archived) { create(:merge_request, title: 'archived mr', author: user, source_project: project2, target_project: project2) }
it 'returns an array excluding merge_requests from archived projects' do
get api(endpoint_path, user)
expect_response_contain_exactly(
merge_request_merged,
merge_request_locked,
merge_request_closed,
merge_request
)
end
context 'with non_archived param set as false' do
it 'returns an array including merge_requests from archived projects' do
path = endpoint_path + '?non_archived=false'
get api(path, user)
expect_response_contain_exactly(
merge_request_merged,
merge_request_locked,
merge_request_closed,
merge_request,
merge_request_archived
)
end
end
end
end
describe "GET /projects/:id/merge_requests/:merge_request_iid" do
......
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