Commit d9bd9682 authored by Tetiana Chupryna's avatar Tetiana Chupryna Committed by Bob Van Landuyt

Expose if user is a bot

parent a32e201d
---
title: Expose if user is a bot in the REST api
merge_request: 52003
author:
type: added
......@@ -264,6 +264,7 @@ Parameters:
"created_at": "2012-05-23T08:00:58Z",
"bio": "",
"bio_html": "",
"bot": false,
"location": null,
"public_email": "john@example.com",
"skype": "",
......
......@@ -6,6 +6,7 @@ module API
include UsersHelper
expose :created_at, if: ->(user, opts) { Ability.allowed?(opts[:current_user], :read_user_profile, user) }
expose :bio, :bio_html, :location, :public_email, :skype, :linkedin, :twitter, :website_url, :organization, :job_title
expose :bot?, as: :bot
expose :work_information do |user|
work_information(user)
end
......
......@@ -23,4 +23,16 @@ RSpec.describe API::Entities::User do
expect(subject).not_to include(:created_at)
end
it 'exposes user as not a bot' do
expect(subject[:bot]).to be_falsey
end
context 'with bot user' do
let(:user) { create(:user, :security_bot) }
it 'exposes user as a bot' do
expect(subject[:bot]).to eq(true)
end
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