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
72c68b98
Commit
72c68b98
authored
Jan 11, 2017
by
Mark Fletcher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Users API to accept confirm parameter
parent
4404ea86
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
1 deletion
+14
-1
changelogs/unreleased/fix-user-api-confirm-param.yml
changelogs/unreleased/fix-user-api-confirm-param.yml
+4
-0
lib/api/users.rb
lib/api/users.rb
+1
-1
spec/requests/api/users_spec.rb
spec/requests/api/users_spec.rb
+9
-0
No files found.
changelogs/unreleased/fix-user-api-confirm-param.yml
0 → 100644
View file @
72c68b98
---
title
:
Fix 500 error when POSTing to Users API with optional confirm param
merge_request
:
author
:
lib/api/users.rb
View file @
72c68b98
...
@@ -93,7 +93,7 @@ module API
...
@@ -93,7 +93,7 @@ module API
# Filter out params which are used later
# Filter out params which are used later
user_params
=
declared_params
(
include_missing:
false
)
user_params
=
declared_params
(
include_missing:
false
)
identity_attrs
=
user_params
.
slice
(
:provider
,
:extern_uid
)
identity_attrs
=
user_params
.
slice
(
:provider
,
:extern_uid
)
confirm
=
params
.
delete
(
:confirm
)
confirm
=
user_
params
.
delete
(
:confirm
)
user
=
User
.
new
(
user_params
.
except
(
:extern_uid
,
:provider
))
user
=
User
.
new
(
user_params
.
except
(
:extern_uid
,
:provider
))
user
.
skip_confirmation!
unless
confirm
user
.
skip_confirmation!
unless
confirm
...
...
spec/requests/api/users_spec.rb
View file @
72c68b98
...
@@ -137,6 +137,15 @@ describe API::Users, api: true do
...
@@ -137,6 +137,15 @@ describe API::Users, api: true do
expect
(
new_user
.
can_create_group
).
to
eq
(
true
)
expect
(
new_user
.
can_create_group
).
to
eq
(
true
)
end
end
it
"creates user with optional attributes"
do
optional_attributes
=
{
confirm:
true
}
attributes
=
attributes_for
(
:user
).
merge
(
optional_attributes
)
post
api
(
'/users'
,
admin
),
attributes
expect
(
response
).
to
have_http_status
(
201
)
end
it
"creates non-admin user"
do
it
"creates non-admin user"
do
post
api
(
'/users'
,
admin
),
attributes_for
(
:user
,
admin:
false
,
can_create_group:
false
)
post
api
(
'/users'
,
admin
),
attributes_for
(
:user
,
admin:
false
,
can_create_group:
false
)
expect
(
response
).
to
have_http_status
(
201
)
expect
(
response
).
to
have_http_status
(
201
)
...
...
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