diff options
author | Valeriy Sizov <vsv2711@gmail.com> | 2012-11-07 03:50:42 -0800 |
---|---|---|
committer | Valeriy Sizov <vsv2711@gmail.com> | 2012-11-07 03:50:42 -0800 |
commit | d6a5e3dad7a8d5aa1eb2220c2c60f068455dbaed (patch) | |
tree | 0add3061531048c554a7cd20ebe79097d8972475 | |
parent | 10d881c9cad92169a3105cff0f02601dad4448cf (diff) | |
parent | cf70439e0a61637a8ad12360c53df08320b937b9 (diff) | |
download | gitlab-ce-d6a5e3dad7a8d5aa1eb2220c2c60f068455dbaed.tar.gz |
Merge pull request #1735 from NARKOZ/api
API fixes
-rw-r--r-- | CHANGELOG | 2 | ||||
-rw-r--r-- | doc/api/users.md | 6 | ||||
-rw-r--r-- | lib/api/users.rb | 11 | ||||
-rw-r--r-- | spec/requests/api/projects_spec.rb | 10 | ||||
-rw-r--r-- | spec/requests/api/users_spec.rb | 8 |
5 files changed, 17 insertions, 20 deletions
diff --git a/CHANGELOG b/CHANGELOG index a4debcc4420..58111484087 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -28,7 +28,7 @@ v 3.0.0 - Reject ssh keys that break gitolite - [API] list one project hook - [API] edit project hook - - [API] add project snippets list + - [API] list project snippets - [API] allow to authorize using private token in HTTP header - [API] add user creation diff --git a/doc/api/users.md b/doc/api/users.md index 63271ee83b0..c116144d91e 100644 --- a/doc/api/users.md +++ b/doc/api/users.md @@ -74,14 +74,12 @@ POST /users Parameters: + `email` (required) - Email -+ `name` (required) - Name + `password` (required) - Password -+ `password_confirmation` (required) - Password confirmation ++ `name` - Name + `skype` - Skype ID + `linkedin` - Linkedin + `twitter` - Twitter account -+ `projects_limit` - Limit projects wich user can create - ++ `projects_limit` - Number of projects user can create Will return created user with status `201 Created` on success, or `404 Not found` on fail. diff --git a/lib/api/users.rb b/lib/api/users.rb index 7f548aaa667..57e0aa108cf 100644 --- a/lib/api/users.rb +++ b/lib/api/users.rb @@ -23,24 +23,23 @@ module Gitlab @user = User.find(params[:id]) present @user, with: Entities::User end - + # Create user. Available only for admin # # Parameters: # email (required) - Email - # name (required) - Name # password (required) - Password - # password_confirmation (required) - Password confirmation + # name - Name # skype - Skype ID # linkedin - Linkedin # twitter - Twitter account - # projects_limit - Limit projects wich user can create + # projects_limit - Number of projects user can create # Example Request: # POST /users post do authenticated_as_admin! - attrs = attributes_for_keys [:email, :name, :password, :password_confirmation, :skype, :linkedin, :twitter, :projects_limit] - user = User.new attrs + attrs = attributes_for_keys [:email, :name, :password, :skype, :linkedin, :twitter, :projects_limit] + user = User.new attrs, as: :admin if user.save present user, with: Entities::User else diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 88bd81969e4..5f9a587d57a 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -46,7 +46,7 @@ describe Gitlab::API do response.status.should == 201 end - it "should repsond with 404 on failure" do + it "should respond with 404 on failure" do post api("/projects", user) response.status.should == 404 end @@ -188,16 +188,16 @@ describe Gitlab::API do }.to change {project.hooks.count}.by(1) end end - + describe "PUT /projects/:id/hooks/:hook_id" do it "should update an existing project hook" do put api("/projects/#{project.code}/hooks/#{hook.id}", user), - url: 'http://example.com' + url: 'http://example.org' response.status.should == 200 - json_response['url'].should == 'http://example.com' + json_response['url'].should == 'http://example.org' end end - + describe "DELETE /projects/:id/hooks" do it "should delete hook from project" do diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb index e3049e09016..4c2e6adaf7f 100644 --- a/spec/requests/api/users_spec.rb +++ b/spec/requests/api/users_spec.rb @@ -4,7 +4,7 @@ describe Gitlab::API do include ApiHelpers let(:user) { Factory :user } - let(:admin) {Factory :admin} + let(:admin) { Factory :admin } let(:key) { Factory :key, user: user } describe "GET /users" do @@ -42,9 +42,9 @@ describe Gitlab::API do end it "should create user" do - expect{ - post api("/users", admin), Factory.attributes(:user) - }.to change{User.count}.by(1) + expect { + post api("/users", admin), Factory.attributes(:user, projects_limit: 3) + }.to change { User.count }.by(1) end it "shouldn't available for non admin users" do |