From 75d76dc7d88e7a601e8d21be17044aa4fedf3ebc Mon Sep 17 00:00:00 2001 From: Rolf Offermanns Date: Wed, 9 Mar 2022 10:01:13 +0100 Subject: [PATCH] Add approve_user method --- lib/gitlab/client/users.rb | 11 +++++++++++ spec/fixtures/user_approve.json | 1 + spec/gitlab/client/users_spec.rb | 15 +++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 spec/fixtures/user_approve.json diff --git a/lib/gitlab/client/users.rb b/lib/gitlab/client/users.rb index b84aa127b..39eb701a5 100644 --- a/lib/gitlab/client/users.rb +++ b/lib/gitlab/client/users.rb @@ -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 diff --git a/spec/fixtures/user_approve.json b/spec/fixtures/user_approve.json new file mode 100644 index 000000000..f32a5804e --- /dev/null +++ b/spec/fixtures/user_approve.json @@ -0,0 +1 @@ +true \ No newline at end of file diff --git a/spec/gitlab/client/users_spec.rb b/spec/gitlab/client/users_spec.rb index 3b3ffc203..715360738 100644 --- a/spec/gitlab/client/users_spec.rb +++ b/spec/gitlab/client/users_spec.rb @@ -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'