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
a4ed0689
Commit
a4ed0689
authored
Sep 01, 2021
by
Serena Fang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use named subject with unblock user specs
parent
b2a851ad
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
34 deletions
+65
-34
spec/requests/api/users_spec.rb
spec/requests/api/users_spec.rb
+65
-34
No files found.
spec/requests/api/users_spec.rb
View file @
a4ed0689
...
...
@@ -2919,32 +2919,75 @@ RSpec.describe API::Users do
end
end
describe
'POST /users/:id/unblock'
do
let
(
:blocked_user
)
{
create
(
:user
,
state:
'blocked'
)
}
let
(
:deactivated_user
)
{
create
(
:user
,
state:
'deactivated'
)
}
describe
'POST /users/:id/unblock'
,
:aggregate_failures
do
context
'when admin'
do
subject
(
:unblock_user
)
{
post
api
(
"/users/
#{
user_id
}
/unblock"
,
admin
)
}
it
'unblocks existing user'
do
post
api
(
"/users/
#{
user
.
id
}
/unblock"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
user
.
reload
.
state
).
to
eq
(
'active'
)
end
context
'with an existing user'
do
let
(
:user_id
)
{
user
.
id
}
it
'unblocks a blocked user'
do
post
api
(
"/users/
#{
blocked_user
.
id
}
/unblock"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
blocked_user
.
reload
.
state
).
to
eq
(
'active'
)
end
it
'unblocks existing user'
do
unblock_user
it
'does not unblock ldap blocked users'
do
post
api
(
"/users/
#{
ldap_blocked_user
.
id
}
/unblock"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
expect
(
ldap_blocked_user
.
reload
.
state
).
to
eq
(
'ldap_blocked'
)
end
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
user
.
reload
.
state
).
to
eq
(
'active'
)
end
end
it
'does not unblock deactivated users'
do
post
api
(
"/users/
#{
deactivated_user
.
id
}
/unblock"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
expect
(
deactivated_user
.
reload
.
state
).
to
eq
(
'deactivated'
)
context
'with a blocked user'
do
let
(
:blocked_user
)
{
create
(
:user
,
state:
'blocked'
)
}
let
(
:user_id
)
{
blocked_user
.
id
}
it
'unblocks a blocked user'
do
unblock_user
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
blocked_user
.
reload
.
state
).
to
eq
(
'active'
)
end
end
context
'with a ldap blocked user'
do
let
(
:user_id
)
{
ldap_blocked_user
.
id
}
it
'does not unblock ldap blocked users'
do
unblock_user
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
expect
(
ldap_blocked_user
.
reload
.
state
).
to
eq
(
'ldap_blocked'
)
end
end
context
'with a deactivated user'
do
let
(
:user_id
)
{
deactivated_user
.
id
}
it
'does not unblock deactivated users'
do
unblock_user
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
expect
(
deactivated_user
.
reload
.
state
).
to
eq
(
'deactivated'
)
end
end
context
'with a non existent user'
do
let
(
:user_id
)
{
non_existing_record_id
}
it
'returns a 404 error if user id not found'
do
unblock_user
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
expect
(
json_response
[
'message'
]).
to
eq
(
'404 User Not Found'
)
end
end
context
'with an invalid id user'
do
let
(
:user_id
)
{
'ASDF'
}
it
"returns a 404 for invalid ID"
do
unblock_user
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
it
'is not available for non admin users'
do
...
...
@@ -2952,18 +2995,6 @@ RSpec.describe API::Users do
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
expect
(
user
.
reload
.
state
).
to
eq
(
'active'
)
end
it
'returns a 404 error if user id not found'
do
post
api
(
'/users/0/block'
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
expect
(
json_response
[
'message'
]).
to
eq
(
'404 User Not Found'
)
end
it
"returns a 404 for invalid ID"
do
post
api
(
"/users/ASDF/block"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
describe
'POST /users/:id/ban'
,
:aggregate_failures
do
...
...
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