Skip to content
Snippets Groups Projects
Commit ab916d32 authored by Izaak Alpert's avatar Izaak Alpert Committed by Wes Gurney
Browse files

Update User api to respect default settings

-API now respects default_projects_limit, default_can_create_group, and default_can_create_team

Change-Id: I059d060d576df1050e5371e707381c5e8c608a7a
parent 9ad75248
No related branches found
No related tags found
1 merge request!4954Add support to configure webhook_timeout in gitlab.yaml
Loading
Loading
@@ -198,6 +198,11 @@ class User < ActiveRecord::Base
User.find_by_username(name_or_id)
end
end
def defaults
{ projects_limit: Gitlab.config.gitlab.default_projects_limit, can_create_group: Gitlab.config.gitlab.default_can_create_group, can_create_team: Gitlab.config.gitlab.default_can_create_team }
end
end
 
#
Loading
Loading
Loading
Loading
@@ -46,7 +46,7 @@ module API
authenticated_as_admin!
required_attributes! [:email, :password, :name, :username]
 
attrs = attributes_for_keys [:email, :name, :password, :skype, :linkedin, :twitter, :projects_limit, :username, :extern_uid, :provider, :bio]
attrs = User.defaults.merge(attributes_for_keys [:email, :name, :password, :skype, :linkedin, :twitter, :projects_limit, :username, :extern_uid, :provider, :bio])
user = User.new attrs, as: :admin
if user.save
present user, with: Entities::User
Loading
Loading
Loading
Loading
@@ -57,6 +57,17 @@ describe API::API do
response.status.should == 201
end
 
it "creating a user should respect default project limit" do
limit = 123456
Gitlab.config.gitlab.stub(:default_projects_limit).and_return(limit)
attr = attributes_for(:user )
expect {
post api("/users", admin), attr
}.to change { User.count }.by(1)
User.find_by_username(attr[:username]).projects_limit.should == limit
Gitlab.config.gitlab.unstub(:default_projects_limit)
end
it "should not create user with invalid email" do
post api("/users", admin), { email: "invalid email", password: 'password' }
response.status.should == 400
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment