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
5bab7895
Commit
5bab7895
authored
Jul 27, 2018
by
Jacopo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve error message when adding invalid user to a project
parent
87f03f01
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
1 deletion
+17
-1
changelogs/unreleased/32821-better-error-message-add-invalid-user-to-project.yml
...2821-better-error-message-add-invalid-user-to-project.yml
+5
-0
lib/api/members.rb
lib/api/members.rb
+4
-1
spec/requests/api/members_spec.rb
spec/requests/api/members_spec.rb
+8
-0
No files found.
changelogs/unreleased/32821-better-error-message-add-invalid-user-to-project.yml
0 → 100644
View file @
5bab7895
---
title
:
Improve error message when adding invalid user to a project
merge_request
:
20885
author
:
Jacopo Beschi @jacopo-beschi
type
:
added
lib/api/members.rb
View file @
5bab7895
...
...
@@ -75,7 +75,10 @@ module API
member
=
source
.
members
.
find_by
(
user_id:
params
[
:user_id
])
conflict!
(
'Member already exists'
)
if
member
member
=
source
.
add_user
(
params
[
:user_id
],
params
[
:access_level
],
current_user:
current_user
,
expires_at:
params
[
:expires_at
])
user
=
User
.
find_by_id
(
params
[
:user_id
])
not_found!
(
'User'
)
unless
user
member
=
source
.
add_user
(
user
,
params
[
:access_level
],
current_user:
current_user
,
expires_at:
params
[
:expires_at
])
if
!
member
not_allowed!
# This currently can only be reached in EE
...
...
spec/requests/api/members_spec.rb
View file @
5bab7895
...
...
@@ -231,6 +231,14 @@ describe API::Members do
expect
(
response
).
to
have_gitlab_http_status
(
409
)
end
it
'returns 404 when the user_id is not valid'
do
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members"
,
maintainer
),
user_id:
0
,
access_level:
Member
::
MAINTAINER
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
json_response
[
'message'
]).
to
eq
(
'404 User Not Found'
)
end
it
'returns 400 when user_id is not given'
do
post
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members"
,
maintainer
),
access_level:
Member
::
MAINTAINER
...
...
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