Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Norman <steve.norman@thomsonreuters.com>2015-04-28 19:02:44 +0300
committerSteve Norman <steve.norman@thomsonreuters.com>2015-07-03 14:17:57 +0300
commitb3a751112ded889769dadc7cc69d2d1467aa9471 (patch)
treecc9f635e07f0ad0b74ae1d5b45b14f1eeebed236 /spec/requests
parent49749169e9b442c13cdc279d7e783f65a3afc794 (diff)
Allow user to be blocked and unblocked via the API
Diffstat (limited to 'spec/requests')
-rw-r--r--spec/requests/api/users_spec.rb51
1 files changed, 51 insertions, 0 deletions
diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb
index 1a29058f3f1..c4dd1f76cf2 100644
--- a/spec/requests/api/users_spec.rb
+++ b/spec/requests/api/users_spec.rb
@@ -527,4 +527,55 @@ describe API::API, api: true do
expect(response.status).to eq(401)
end
end
+
+ describe 'PUT /user/:id/block' do
+ before { admin }
+ it 'should block existing user' do
+ put api("/users/#{user.id}/block", admin)
+ expect(response.status).to eq(200)
+ expect(user.reload.state).to eq('blocked')
+ end
+
+ it 'should not be available for non admin users' do
+ put api("/users/#{user.id}/block", user)
+ expect(response.status).to eq(403)
+ expect(user.reload.state).to eq('active')
+ end
+
+ it 'should return a 404 error if user id not found' do
+ put api('/users/9999/block', admin)
+ expect(response.status).to eq(404)
+ expect(json_response['message']).to eq('404 User Not Found')
+ end
+ end
+
+ describe 'PUT /user/:id/unblock' do
+ before { admin }
+ it 'should unblock existing user' do
+ put api("/users/#{user.id}/unblock", admin)
+ expect(response.status).to eq(200)
+ expect(user.reload.state).to eq('active')
+ end
+
+ it 'should unblock a blocked user' do
+ put api("/users/#{user.id}/block", admin)
+ expect(response.status).to eq(200)
+ expect(user.reload.state).to eq('blocked')
+ put api("/users/#{user.id}/unblock", admin)
+ expect(response.status).to eq(200)
+ expect(user.reload.state).to eq('active')
+ end
+
+ it 'should not be available for non admin users' do
+ put api("/users/#{user.id}/unblock", user)
+ expect(response.status).to eq(403)
+ expect(user.reload.state).to eq('active')
+ end
+
+ it 'should return a 404 error if user id not found' do
+ put api('/users/9999/block', admin)
+ expect(response.status).to eq(404)
+ expect(json_response['message']).to eq('404 User Not Found')
+ end
+ end
end