diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-01-31 15:00:50 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-01-31 15:00:50 +0400 |
commit | fd1b9fdc12f0fac112810851903203bc256b6548 (patch) | |
tree | ead4e97e0b6a6cc22f080e33135756d9b0702d9e /spec | |
parent | afdb09de80191d9424c34b7bab3e2f8d5fd1c782 (diff) | |
parent | e954438a1d3a45addebf52ab04155459d7d84db0 (diff) |
Merge branch 'extend_user_api' of https://github.com/bladealslayer/gitlabhq into bladealslayer-extend_user_api
Conflicts:
spec/requests/api/users_spec.rb
Diffstat (limited to 'spec')
-rw-r--r-- | spec/requests/api/users_spec.rb | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb index ee5f510aac5..1645117e231 100644 --- a/spec/requests/api/users_spec.rb +++ b/spec/requests/api/users_spec.rb @@ -83,6 +83,54 @@ describe Gitlab::API do end end + describe "PUT /users/:id" do + before { admin } + + it "should update user" do + put api("/users/#{user.id}", admin), {bio: 'new test bio'} + response.status.should == 200 + json_response['bio'].should == 'new test bio' + user.reload.bio.should == 'new test bio' + end + + it "should not allow invalid update" do + put api("/users/#{user.id}", admin), {email: 'invalid email'} + response.status.should == 404 + user.reload.email.should_not == 'invalid email' + end + + it "shouldn't available for non admin users" do + put api("/users/#{user.id}", user), attributes_for(:user) + response.status.should == 403 + end + + it "should return 404 for non-existing user" do + put api("/users/999999", admin), {bio: 'update should fail'} + response.status.should == 404 + end + end + + describe "DELETE /users/:id" do + before { admin } + + it "should delete user" do + delete api("/users/#{user.id}", admin) + response.status.should == 200 + expect { User.find(user.id) }.to raise_error ActiveRecord::RecordNotFound + json_response['email'].should == user.email + end + + it "shouldn't available for non admin users" do + delete api("/users/#{user.id}", user) + response.status.should == 403 + end + + it "should return 404 for non-existing user" do + delete api("/users/999999", admin) + response.status.should == 404 + end + end + describe "GET /user" do it "should return current user" do get api("/user", user) |