Commit 8e8c0dbb authored by Serena Fang's avatar Serena Fang

Add specs for unban and ff disabled

Apply MR review suggestions

Add version history
parent f1b1e1df
......@@ -119,6 +119,8 @@ A deactivated user can also activate their account themselves by logging back in
## Ban and unban users
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/327353) in GitLab 13.12.
GitLab administrators can ban users.
NOTE:
......
......@@ -366,6 +366,7 @@ RSpec.describe Admin::UsersController do
end
describe 'PUT ban/:id' do
context 'when ban_user_feature_flag is enabled' do
it 'bans user' do
put :ban, params: { id: user.username }
......@@ -387,6 +388,33 @@ RSpec.describe Admin::UsersController do
end
end
context 'when ban_user_feature_flag is not enabled' do
before do
stub_feature_flags(ban_user_feature_flag: false)
end
it 'does not ban user, renders 404' do
put :ban, params: { id: user.username }
user.reload
expect(user.banned?).to be_falsey
expect(response).to have_gitlab_http_status(:not_found)
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
before do
request.env["HTTP_REFERER"] = "/"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment