Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
d9bd9682
Commit
d9bd9682
authored
Feb 01, 2021
by
Tetiana Chupryna
Committed by
Bob Van Landuyt
Feb 01, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose if user is a bot
parent
a32e201d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
0 deletions
+19
-0
changelogs/unreleased/267140-check-if-user-is-bot.yml
changelogs/unreleased/267140-check-if-user-is-bot.yml
+5
-0
doc/api/users.md
doc/api/users.md
+1
-0
lib/api/entities/user.rb
lib/api/entities/user.rb
+1
-0
spec/lib/api/entities/user_spec.rb
spec/lib/api/entities/user_spec.rb
+12
-0
No files found.
changelogs/unreleased/267140-check-if-user-is-bot.yml
0 → 100644
View file @
d9bd9682
---
title
:
Expose if user is a bot in the REST api
merge_request
:
52003
author
:
type
:
added
doc/api/users.md
View file @
d9bd9682
...
...
@@ -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"
:
""
,
...
...
lib/api/entities/user.rb
View file @
d9bd9682
...
...
@@ -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
...
...
spec/lib/api/entities/user_spec.rb
View file @
d9bd9682
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment