Commit 66aae34b authored by Serena Fang's avatar Serena Fang

Expose is_auditor user role via API

Similar to how we expose is_admin when
using the user API as an admin,
provide is_auditor field

Changelog: changed

Add changelog entry
parent 0b2d6f3f
---
title: Expose is_auditor user role via API
merge_request: 61058
author:
type: changed
......@@ -4,6 +4,7 @@ module API
module Entities
class UserWithAdmin < UserPublic
expose :admin?, as: :is_admin
expose :auditor, as: :is_auditor
expose :note
end
end
......
......@@ -536,6 +536,13 @@ RSpec.describe API::Users do
expect(json_response.keys).not_to include 'is_admin'
end
it "does not return the user's `is_auditor` flag" do
get api("/users/#{user.id}", user)
expect(response).to match_response_schema('public_api/v4/user/basic')
expect(json_response.keys).not_to include 'is_auditor'
end
it "does not return the user's `highest_role`" do
get api("/users/#{user.id}", user)
......@@ -582,6 +589,13 @@ RSpec.describe API::Users do
expect(json_response['is_admin']).to be(false)
end
it 'includes the `is_auditor` field' do
get api("/users/#{user.id}", admin)
expect(response).to match_response_schema('public_api/v4/user/admin')
expect(json_response['is_auditor']).to be(false)
end
it "includes the `created_at` field for private users" do
get api("/users/#{private_user.id}", admin)
......
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