API on adding users to project implemented

This commit is contained in:
miks 2012-09-05 23:01:03 +03:00
parent 19a5219746
commit 8f7360f390
3 changed files with 39 additions and 0 deletions

View file

@ -106,6 +106,21 @@ Parameters:
Will return created project with status `201 Created` on success, or `404 Not
found` on fail.
## Add project users
Add users to exiting project
```
PUT /projects/:id/add_users
```
Parameters:
+ `id` (required) - The ID or code name of a project
+ `user_ids` (required) - new project name
+ `project_access` (required) - new project name
Will return updated project with status `200 OK` on success, or `404 Not found` on fail.
## Project repository branches

View file

@ -44,6 +44,18 @@ module Gitlab
end
end
# Add users to project with specified access level
#
# Parameters:
# id (required) - The ID or code name of a project
# user_ids (required) - The ID list of users to add
# project_access (required) - Project access level
# Example Request:
# PUT /projects/:id/add_users
put ":id/add_users" do
user_project.add_users_ids_to_team(params[:user_ids], params[:project_access])
end
# Get a project repository branches
#
# Parameters:

View file

@ -62,6 +62,18 @@ describe Gitlab::API do
end
end
describe "PUT /projects/:id/add_users" do
@user2 = Factory :user
@user3 = Factory :user
it "should add users to existing project" do
expect {
put api("/projects/#{project.code}/add_users", user),
user_ids: [@user2.id, @user3.id], project_access: UsersProject::DEVELOPER
}.to change {Project.users_projects.where(:project_access => UsersProject::DEVELOPER).count}.by(2)
end
end
describe "GET /projects/:id" do
it "should return a project by id" do
get api("/projects/#{project.id}", user)