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
492d28e7
Commit
492d28e7
authored
Apr 09, 2020
by
Magdalena Frankiewicz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose work information on User
parent
4010b8aa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
0 deletions
+30
-0
lib/api/entities/user.rb
lib/api/entities/user.rb
+4
-0
spec/lib/api/entities/user_spec.rb
spec/lib/api/entities/user_spec.rb
+26
-0
No files found.
lib/api/entities/user.rb
View file @
492d28e7
...
...
@@ -3,8 +3,12 @@
module
API
module
Entities
class
User
<
UserBasic
include
UsersHelper
expose
:created_at
,
if:
->
(
user
,
opts
)
{
Ability
.
allowed?
(
opts
[
:current_user
],
:read_user_profile
,
user
)
}
expose
:bio
,
:location
,
:public_email
,
:skype
,
:linkedin
,
:twitter
,
:website_url
,
:organization
,
:job_title
expose
:work_information
do
|
user
|
work_information
(
user
)
end
end
end
end
spec/lib/api/entities/user_spec.rb
0 → 100644
View file @
492d28e7
# frozen_string_literal: true
require
'spec_helper'
describe
API
::
Entities
::
User
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:current_user
)
{
create
(
:user
)
}
subject
{
described_class
.
new
(
user
,
current_user:
current_user
).
as_json
}
it
'exposes correct attributes'
do
expect
(
subject
).
to
include
(
:bio
,
:location
,
:public_email
,
:skype
,
:linkedin
,
:twitter
,
:website_url
,
:organization
,
:job_title
,
:work_information
)
end
it
'exposes created_at if the current user can read the user profile'
do
allow
(
Ability
).
to
receive
(
:allowed?
).
with
(
current_user
,
:read_user_profile
,
user
).
and_return
(
true
)
expect
(
subject
).
to
include
(
:created_at
)
end
it
'does not expose created_at if the current user cannot read the user profile'
do
allow
(
Ability
).
to
receive
(
:allowed?
).
with
(
current_user
,
:read_user_profile
,
user
).
and_return
(
false
)
expect
(
subject
).
not_to
include
(
:created_at
)
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