diff --git a/lib/gitlab/client/projects.rb b/lib/gitlab/client/projects.rb index 0109b4135..400f75e00 100644 --- a/lib/gitlab/client/projects.rb +++ b/lib/gitlab/client/projects.rb @@ -102,6 +102,22 @@ def team_members(project, options = {}) get("/projects/#{url_encode project}/members", query: options) end + # Gets a list of all project team members including inherited members. + # + # @example + # Gitlab.all_members(42) + # Gitlab.all_members('gitlab') + # + # @param [Integer, String] project The ID or path of a project. + # @param [Hash] options A customizable set of options. + # @option options [String] :query The search query. + # @option options [Integer] :page The page number. + # @option options [Integer] :per_page The number of results per page. + # @return [Array] + def all_members(project, options = {}) + get("/projects/#{url_encode project}/members/all", query: options) + end + # Gets a project team member. # # @example diff --git a/spec/gitlab/client/projects_spec.rb b/spec/gitlab/client/projects_spec.rb index 1adb9e8a7..3f8bd0722 100644 --- a/spec/gitlab/client/projects_spec.rb +++ b/spec/gitlab/client/projects_spec.rb @@ -170,6 +170,22 @@ end end + describe '.all_members' do + before do + stub_get('/projects/3/members/all', 'team_members') + @all_members = Gitlab.all_members(3) + end + + it 'gets the correct resource' do + expect(a_get('/projects/3/members/all')).to have_been_made + end + + it 'returns a paginated response of all team members including inherited' do + expect(@all_members).to be_a Gitlab::PaginatedResponse + expect(@all_members.first.name).to eq('John Smith') + end + end + describe '.team_member' do before do stub_get('/projects/3/members/1', 'team_member')