Skip to content

Commit

Permalink
Add block/unblock user. This API feature was added in GitLab 7.13
Browse files Browse the repository at this point in the history
  • Loading branch information
azomazo committed Jul 25, 2015
1 parent 9946c7d commit 3179bed
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lib/gitlab/client/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,28 @@ def delete_user(user_id)
delete("/users/#{user_id}")
end

# Blocks the specified user. Available only for admin.
#
# @example
# Gitlab.block_user(15)
#
# @param [Integer] user_id The Id of user
# @return [Boolean] success or not
def block_user(user_id)
put("/users/#{user_id}/block")
end

# Unblocks the specified user. Available only for admin.
#
# @example
# Gitlab.unblock_user(15)
#
# @param [Integer] user_id The Id of user
# @return [Boolean] success or not
def unblock_user(user_id)
put("/users/#{user_id}/unblock")
end

# Creates a new user session.
#
# @example
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/user_block_unblock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
true
30 changes: 30 additions & 0 deletions spec/gitlab/client/users_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,36 @@
end
end

describe ".block_user" do
before do
stub_put("/users/1/block", "user_block_unblock")
@result = Gitlab.block_user(1)
end

it "should get the correct resource" do
expect(a_put("/users/1/block")).to have_been_made
end

it "should return boolean" do
expect(@result).to eq(true)
end
end

describe ".unblock_user" do
before do
stub_put("/users/1/unblock", "user_block_unblock")
@result = Gitlab.unblock_user(1)
end

it "should get the correct resource" do
expect(a_put("/users/1/unblock")).to have_been_made
end

it "should return boolean" do
expect(@result).to eq(true)
end
end

describe ".session" do
after do
Gitlab.endpoint = 'https://api.example.com'
Expand Down

0 comments on commit 3179bed

Please sign in to comment.