summaryrefslogtreecommitdiff
path: root/spec/requests
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-09-29 23:03:46 -0700
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-09-29 23:03:46 -0700
commit836104b41a557e8411d422c0dca7930e85b0de95 (patch)
tree5a45ebe5475209a098a6c8d818488ef35d18030e /spec/requests
parente48c6fab60d57b4af31f5b5d3e81ba09e4e68881 (diff)
parent5b657a65d4ec309be2cb7dfcacf85e98d59a4eb0 (diff)
downloadgitlab-ce-836104b41a557e8411d422c0dca7930e85b0de95.tar.gz
Merge pull request #5213 from bladealslayer/feature/user_api_extended
Extended User API to expose admin and can_create_group for user creation...
Diffstat (limited to 'spec/requests')
-rw-r--r--spec/requests/api/users_spec.rb47
1 files changed, 46 insertions, 1 deletions
diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb
index 2fced3ec945..4ef78b8e5d0 100644
--- a/spec/requests/api/users_spec.rb
+++ b/spec/requests/api/users_spec.rb
@@ -52,6 +52,35 @@ describe API::API do
}.to change { User.count }.by(1)
end
+ it "should create user with correct attributes" do
+ post api('/users', admin), attributes_for(:user, admin: true, can_create_group: true)
+ response.status.should == 201
+ user_id = json_response['id']
+ new_user = User.find(user_id)
+ new_user.should_not == nil
+ new_user.admin.should == true
+ new_user.can_create_group.should == true
+ end
+
+ it "should create non-admin user" do
+ post api('/users', admin), attributes_for(:user, admin: false, can_create_group: false)
+ response.status.should == 201
+ user_id = json_response['id']
+ new_user = User.find(user_id)
+ new_user.should_not == nil
+ new_user.admin.should == false
+ new_user.can_create_group.should == false
+ end
+
+ it "should create non-admin users by default" do
+ post api('/users', admin), attributes_for(:user)
+ response.status.should == 201
+ user_id = json_response['id']
+ new_user = User.find(user_id)
+ new_user.should_not == nil
+ new_user.admin.should == false
+ end
+
it "should return 201 Created on success" do
post api("/users", admin), attributes_for(:user, projects_limit: 3)
response.status.should == 201
@@ -135,6 +164,8 @@ describe API::API do
end
describe "PUT /users/:id" do
+ let!(:admin_user) { create(:admin) }
+
before { admin }
it "should update user with new bio" do
@@ -144,6 +175,21 @@ describe API::API do
user.reload.bio.should == 'new test bio'
end
+ it "should update admin status" do
+ put api("/users/#{user.id}", admin), {admin: true}
+ response.status.should == 200
+ json_response['is_admin'].should == true
+ user.reload.admin.should == true
+ end
+
+ it "should not update admin status" do
+ put api("/users/#{admin_user.id}", admin), {can_create_group: false}
+ response.status.should == 200
+ json_response['is_admin'].should == true
+ admin_user.reload.admin.should == true
+ admin_user.can_create_group.should == false
+ end
+
it "should not allow invalid update" do
put api("/users/#{user.id}", admin), {email: 'invalid email'}
response.status.should == 404
@@ -228,7 +274,6 @@ describe API::API do
response.status.should == 200
json_response['email'].should == user.email
json_response['is_admin'].should == user.is_admin?
- json_response['can_create_team'].should == user.can_create_team?
json_response['can_create_project'].should == user.can_create_project?
json_response['can_create_group'].should == user.can_create_group?
end