Commit 8f7360f3901ae27a457f252b1a9a091a857434ee
1 parent
19a52197
Exists in
master
and in
4 other branches
API on adding users to project implemented
Showing
3 changed files
with
39 additions
and
0 deletions
Show diff stats
doc/api/projects.md
... | ... | @@ -106,6 +106,21 @@ Parameters: |
106 | 106 | Will return created project with status `201 Created` on success, or `404 Not |
107 | 107 | found` on fail. |
108 | 108 | |
109 | +## Add project users | |
110 | + | |
111 | +Add users to exiting project | |
112 | + | |
113 | +``` | |
114 | +PUT /projects/:id/add_users | |
115 | +``` | |
116 | + | |
117 | +Parameters: | |
118 | + | |
119 | ++ `id` (required) - The ID or code name of a project | |
120 | ++ `user_ids` (required) - new project name | |
121 | ++ `project_access` (required) - new project name | |
122 | + | |
123 | +Will return updated project with status `200 OK` on success, or `404 Not found` on fail. | |
109 | 124 | |
110 | 125 | ## Project repository branches |
111 | 126 | ... | ... |
lib/api/projects.rb
... | ... | @@ -44,6 +44,18 @@ module Gitlab |
44 | 44 | end |
45 | 45 | end |
46 | 46 | |
47 | + # Add users to project with specified access level | |
48 | + # | |
49 | + # Parameters: | |
50 | + # id (required) - The ID or code name of a project | |
51 | + # user_ids (required) - The ID list of users to add | |
52 | + # project_access (required) - Project access level | |
53 | + # Example Request: | |
54 | + # PUT /projects/:id/add_users | |
55 | + put ":id/add_users" do | |
56 | + user_project.add_users_ids_to_team(params[:user_ids], params[:project_access]) | |
57 | + end | |
58 | + | |
47 | 59 | # Get a project repository branches |
48 | 60 | # |
49 | 61 | # Parameters: | ... | ... |
spec/requests/api/projects_spec.rb
... | ... | @@ -62,6 +62,18 @@ describe Gitlab::API do |
62 | 62 | end |
63 | 63 | end |
64 | 64 | |
65 | + describe "PUT /projects/:id/add_users" do | |
66 | + @user2 = Factory :user | |
67 | + @user3 = Factory :user | |
68 | + | |
69 | + it "should add users to existing project" do | |
70 | + expect { | |
71 | + put api("/projects/#{project.code}/add_users", user), | |
72 | + user_ids: [@user2.id, @user3.id], project_access: UsersProject::DEVELOPER | |
73 | + }.to change {Project.users_projects.where(:project_access => UsersProject::DEVELOPER).count}.by(2) | |
74 | + end | |
75 | + end | |
76 | + | |
65 | 77 | describe "GET /projects/:id" do |
66 | 78 | it "should return a project by id" do |
67 | 79 | get api("/projects/#{project.id}", user) | ... | ... |