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
8e8c0dbb
Commit
8e8c0dbb
authored
May 12, 2021
by
Serena Fang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for unban and ff disabled
Apply MR review suggestions Add version history
parent
f1b1e1df
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
9 deletions
+39
-9
doc/user/admin_area/moderate_users.md
doc/user/admin_area/moderate_users.md
+2
-0
spec/controllers/admin/users_controller_spec.rb
spec/controllers/admin/users_controller_spec.rb
+37
-9
No files found.
doc/user/admin_area/moderate_users.md
View file @
8e8c0dbb
...
@@ -119,6 +119,8 @@ A deactivated user can also activate their account themselves by logging back in
...
@@ -119,6 +119,8 @@ A deactivated user can also activate their account themselves by logging back in
## Ban and unban users
## Ban and unban users
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/327353) in GitLab 13.12.
GitLab administrators can ban users.
GitLab administrators can ban users.
NOTE:
NOTE:
...
...
spec/controllers/admin/users_controller_spec.rb
View file @
8e8c0dbb
...
@@ -366,27 +366,55 @@ RSpec.describe Admin::UsersController do
...
@@ -366,27 +366,55 @@ RSpec.describe Admin::UsersController do
end
end
describe
'PUT ban/:id'
do
describe
'PUT ban/:id'
do
it
'bans user'
do
context
'when ban_user_feature_flag is enabled'
do
put
:ban
,
params:
{
id:
user
.
username
}
it
'bans user'
do
put
:ban
,
params:
{
id:
user
.
username
}
user
.
reload
user
.
reload
expect
(
user
.
banned?
).
to
be_truthy
expect
(
user
.
banned?
).
to
be_truthy
expect
(
flash
[
:notice
]).
to
eq
_
(
'Successfully banned'
)
expect
(
flash
[
:notice
]).
to
eq
_
(
'Successfully banned'
)
end
context
'when unsuccessful'
do
let
(
:user
)
{
create
(
:user
,
:blocked
)
}
it
'does not ban user'
do
put
:ban
,
params:
{
id:
user
.
username
}
user
.
reload
expect
(
user
.
banned?
).
to
be_falsey
expect
(
flash
[
:alert
]).
to
eq
_
(
'Error occurred. User was not banned'
)
end
end
end
end
context
'when unsuccessful'
do
context
'when ban_user_feature_flag is not enabled'
do
let
(
:user
)
{
create
(
:user
,
:blocked
)
}
before
do
stub_feature_flags
(
ban_user_feature_flag:
false
)
end
it
'does not ban user'
do
it
'does not ban user
, renders 404
'
do
put
:ban
,
params:
{
id:
user
.
username
}
put
:ban
,
params:
{
id:
user
.
username
}
user
.
reload
user
.
reload
expect
(
user
.
banned?
).
to
be_falsey
expect
(
user
.
banned?
).
to
be_falsey
expect
(
flash
[
:alert
]).
to
eq
_
(
'Error occurred. User was not banned'
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
end
end
describe
'PUT unban/:id'
do
let
(
:banned_user
)
{
create
(
:user
,
:banned
)
}
it
'unbans user'
do
put
:unban
,
params:
{
id:
banned_user
.
username
}
banned_user
.
reload
expect
(
banned_user
.
banned?
).
to
be_falsey
expect
(
flash
[
:notice
]).
to
eq
_
(
'Successfully unbanned'
)
end
end
describe
'PUT unlock/:id'
do
describe
'PUT unlock/:id'
do
before
do
before
do
request
.
env
[
"HTTP_REFERER"
]
=
"/"
request
.
env
[
"HTTP_REFERER"
]
=
"/"
...
...
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