Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add approve_user method #634

Merged
merged 2 commits into from
Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/gitlab/client/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,17 @@ def unblock_user(user_id)
post("/users/#{user_id}/unblock")
end

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

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

describe '.approve_user' do
before do
stub_post('/users/1/approve', 'user_approve')
@result = Gitlab.approve_user(1)
end

it 'gets the correct resource' do
expect(a_post('/users/1/approve')).to have_been_made
end

it 'returns boolean' do
expect(@result).to eq(true)
end
end

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