Skip to content
代码片段 群组 项目
提交 0efe495c 编辑于 作者: Jan Provaznik's avatar Jan Provaznik
浏览文件

Merge branch 'expose-is-auditor' into 'master'

Expose is_auditor user role via API [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!61058
No related branches found
No related tags found
无相关合并请求
...@@ -190,7 +190,7 @@ GET /users ...@@ -190,7 +190,7 @@ GET /users
] ]
``` ```
Users on GitLab [Premium or higher](https://about.gitlab.com/pricing/) also see the `shared_runners_minutes_limit`, `extra_shared_runners_minutes_limit`, and `using_license_seat` parameters. Users on GitLab [Premium or higher](https://about.gitlab.com/pricing/) also see the `shared_runners_minutes_limit`, `extra_shared_runners_minutes_limit`, `is_auditor`, and `using_license_seat` parameters.
```json ```json
[ [
...@@ -199,6 +199,7 @@ Users on GitLab [Premium or higher](https://about.gitlab.com/pricing/) also see ...@@ -199,6 +199,7 @@ Users on GitLab [Premium or higher](https://about.gitlab.com/pricing/) also see
... ...
"shared_runners_minutes_limit": 133, "shared_runners_minutes_limit": 133,
"extra_shared_runners_minutes_limit": 133, "extra_shared_runners_minutes_limit": 133,
"is_auditor": false,
"using_license_seat": true "using_license_seat": true
... ...
} }
...@@ -359,12 +360,13 @@ NOTE: ...@@ -359,12 +360,13 @@ NOTE:
The `plan` and `trial` parameters are only available on GitLab Enterprise Edition. The `plan` and `trial` parameters are only available on GitLab Enterprise Edition.
Users on GitLab [Premium or higher](https://about.gitlab.com/pricing/) also see Users on GitLab [Premium or higher](https://about.gitlab.com/pricing/) also see
the `shared_runners_minutes_limit`, and `extra_shared_runners_minutes_limit` parameters. the `shared_runners_minutes_limit`, `is_auditor`, and `extra_shared_runners_minutes_limit` parameters.
```json ```json
{ {
"id": 1, "id": 1,
"username": "john_smith", "username": "john_smith",
"is_auditor": false,
"shared_runners_minutes_limit": 133, "shared_runners_minutes_limit": 133,
"extra_shared_runners_minutes_limit": 133, "extra_shared_runners_minutes_limit": 133,
... ...
...@@ -628,6 +630,8 @@ GET /user ...@@ -628,6 +630,8 @@ GET /user
} }
``` ```
Users on GitLab [Premium or higher](https://about.gitlab.com/pricing/) also see the `shared_runners_minutes_limit`, `extra_shared_runners_minutes_limit`, `is_auditor`, and `using_license_seat` parameters.
## User status ## User status
Get the status of the currently signed in user. Get the status of the currently signed in user.
......
---
title: Expose is_auditor user role via API
merge_request: 61058
author:
type: changed
...@@ -8,6 +8,7 @@ module UserWithAdmin ...@@ -8,6 +8,7 @@ module UserWithAdmin
prepended do prepended do
expose :using_license_seat?, as: :using_license_seat expose :using_license_seat?, as: :using_license_seat
expose :auditor, as: :is_auditor, if: ->(_instance, _opts) { ::License.feature_available?(:auditor_user) }
end end
end end
end end
......
...@@ -23,4 +23,30 @@ ...@@ -23,4 +23,30 @@
end end
end end
end end
context 'is_auditor' do
context 'when auditor_user is available' do
it 'returns false when user is not an auditor' do
expect(subject[:is_auditor]).to be false
end
context 'when user is an auditor' do
let(:user) { create(:user, :auditor) }
it 'returns true' do
expect(subject[:is_auditor]).to be true
end
end
end
context 'when auditor_user is not available' do
before do
stub_licensed_features(auditor_user: false)
end
it 'does not have the is_auditor param' do
expect(subject[:is_auditor]).to be nil
end
end
end
end end
...@@ -197,6 +197,12 @@ ...@@ -197,6 +197,12 @@
expect(json_response).to include('plan' => 'ultimate', 'trial' => true) expect(json_response).to include('plan' => 'ultimate', 'trial' => true)
end end
end end
it 'contains is_auditor parameter' do
get api("/users/#{user.id}", admin)
expect(json_response).to have_key('is_auditor')
end
end end
context 'and user has no plan' do context 'and user has no plan' do
...@@ -215,6 +221,12 @@ ...@@ -215,6 +221,12 @@
expect(json_response).not_to have_key('plan') expect(json_response).not_to have_key('plan')
expect(json_response).not_to have_key('trial') expect(json_response).not_to have_key('trial')
end end
it 'does not contain is_auditor parameter' do
get api("/users/#{user.id}", user)
expect(json_response).not_to have_key('is_auditor')
end
end end
end end
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册