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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
d919f924
Commit
d919f924
authored
Jun 06, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backport
https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/1942
parent
34f925fe
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
12 deletions
+15
-12
app/models/user.rb
app/models/user.rb
+1
-1
lib/api/groups.rb
lib/api/groups.rb
+1
-3
lib/api/users.rb
lib/api/users.rb
+0
-4
spec/models/user_spec.rb
spec/models/user_spec.rb
+4
-0
spec/requests/api/users_spec.rb
spec/requests/api/users_spec.rb
+9
-4
No files found.
app/models/user.rb
View file @
d919f924
...
...
@@ -66,7 +66,7 @@ class User < ActiveRecord::Base
#
# Namespace for personal projects
has_one
:namespace
,
->
{
where
type:
nil
},
dependent: :destroy
,
foreign_key: :owner_id
has_one
:namespace
,
->
{
where
type:
nil
},
dependent: :destroy
,
foreign_key: :owner_id
,
autosave:
true
# Profile
has_many
:keys
,
->
do
...
...
lib/api/groups.rb
View file @
d919f924
...
...
@@ -83,7 +83,7 @@ module API
group
=
::
Groups
::
CreateService
.
new
(
current_user
,
declared_params
(
include_missing:
false
)).
execute
if
group
.
persisted?
present
group
,
with:
Entities
::
Group
,
current_user:
current_user
present
group
,
with:
Entities
::
Group
Detail
,
current_user:
current_user
else
render_api_error!
(
"Failed to save group
#{
group
.
errors
.
messages
}
"
,
400
)
end
...
...
@@ -101,8 +101,6 @@ module API
optional
:name
,
type:
String
,
desc:
'The name of the group'
optional
:path
,
type:
String
,
desc:
'The path of the group'
use
:optional_params
at_least_one_of
:name
,
:path
,
:description
,
:visibility
,
:lfs_enabled
,
:request_access_enabled
end
put
':id'
do
group
=
find_group!
(
params
[
:id
])
...
...
lib/api/users.rb
View file @
d919f924
...
...
@@ -124,10 +124,6 @@ module API
optional
:name
,
type:
String
,
desc:
'The name of the user'
optional
:username
,
type:
String
,
desc:
'The username of the user'
use
:optional_attributes
at_least_one_of
:email
,
:password
,
:name
,
:username
,
:skype
,
:linkedin
,
:twitter
,
:website_url
,
:organization
,
:projects_limit
,
:extern_uid
,
:provider
,
:bio
,
:location
,
:admin
,
:can_create_group
,
:confirm
,
:external
end
put
":id"
do
authenticated_as_admin!
...
...
spec/models/user_spec.rb
View file @
d919f924
...
...
@@ -13,6 +13,10 @@ describe User, models: true do
it
{
is_expected
.
to
include_module
(
TokenAuthenticatable
)
}
end
describe
'delegations'
do
it
{
is_expected
.
to
delegate_method
(
:path
).
to
(
:namespace
).
with_prefix
}
end
describe
'associations'
do
it
{
is_expected
.
to
have_one
(
:namespace
)
}
it
{
is_expected
.
to
have_many
(
:snippets
).
dependent
(
:destroy
)
}
...
...
spec/requests/api/users_spec.rb
View file @
d919f924
...
...
@@ -426,9 +426,14 @@ describe API::Users do
expect
(
user
.
reload
.
email
).
not_to
eq
(
'invalid email'
)
end
it
"is not available for non admin users"
do
put
api
(
"/users/
#{
user
.
id
}
"
,
user
),
attributes_for
(
:user
)
expect
(
response
).
to
have_http_status
(
403
)
context
'when the current user is not an admin'
do
it
"is not available"
do
expect
do
put
api
(
"/users/
#{
user
.
id
}
"
,
user
),
attributes_for
(
:user
)
end
.
not_to
change
{
user
.
reload
.
attributes
}
expect
(
response
).
to
have_http_status
(
403
)
end
end
it
"returns 404 for non-existing user"
do
...
...
@@ -649,7 +654,7 @@ describe API::Users do
end
it
"returns a 404 for invalid ID"
do
pu
t
api
(
"/users/ASDF/emails"
,
admin
)
ge
t
api
(
"/users/ASDF/emails"
,
admin
)
expect
(
response
).
to
have_http_status
(
404
)
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