Fixed label groups subscription API to be consistent with the WebUI
What does this MR do?
Labels groups subscription API on search is returning subscribed false even on subscribed label.
The code added is based on the code used on the WebUI in label_subscription_status().
The issue can be reproduced on labels?search=:label_id
and on labels/:label_id
.
Added tests to cover the search aspect of both the project and group label APIs.
Conformity
- [y] I have included changelog trailers, or none are needed. (Does this MR need a changelog?)
- [y] I have added/updated documentation, or it's not needed. (Is documentation required?)
- [y] I have properly separated EE content from FOSS, or this MR is FOSS only. (Where should EE code go?)
- [y] I have added information for database reviewers in the MR description, or it's not needed. (Does this MR have database related changes?)
- [y] I have self-reviewed this MR per code review guidelines.
- [y] This MR does not harm performance, or I have asked a reviewer to help assess the performance impact. (Merge request performance guidelines)
- [y] I have followed the style guides.
- [y] This change is backwards compatible across updates, or this does not apply.
Availability and Testing
The labels below were used for testing and a subscription to each of them was made via web UI, tests realized against 25bf1.
Group label: | Project label: |
---|---|
Id: 41 Title: Ambalt | Id: 44 Title: Aquapod |
curl -sH "$COM_GITLAB_TOKEN" "$GITLAB_URL/api/v4/groups/26/labels?search=Ambalt" | jq
[
{
"id": 41,
"name": "Ambalt",
"color": "#41d16d",
"description": null,
"description_html": "",
"text_color": "#FFFFFF",
"subscribed": false
}
]
curl -sH "$COM_GITLAB_TOKEN" "$GITLAB_URL/api/v4/projects/6/labels?search=Aquapod" | jq
[
{
"id": 44,
"name": "Aquapod",
"color": "#1e840e",
"description": null,
"description_html": "",
"text_color": "#FFFFFF",
"subscribed": true,
"priority": null,
"is_project_label": false
}
]
- [Y] I have added/updated tests following the Testing Guide, or it's not needed. (Consider all test levels. See the Test Planning Process.)