Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kazuhiko Shiozaki
gitlab-ce
Commits
4caaea82
Commit
4caaea82
authored
May 27, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dmedvinsky-add-defaults-create-group-team'
parents
01d8c7d6
ec105507
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
63 additions
and
8 deletions
+63
-8
app/controllers/admin/users_controller.rb
app/controllers/admin/users_controller.rb
+1
-1
app/controllers/registrations_controller.rb
app/controllers/registrations_controller.rb
+1
-2
app/models/user.rb
app/models/user.rb
+8
-0
config/gitlab.yml.example
config/gitlab.yml.example
+4
-2
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+12
-1
lib/gitlab/auth.rb
lib/gitlab/auth.rb
+1
-2
spec/features/admin/admin_users_spec.rb
spec/features/admin/admin_users_spec.rb
+8
-0
spec/lib/auth_spec.rb
spec/lib/auth_spec.rb
+10
-0
spec/models/user_spec.rb
spec/models/user_spec.rb
+18
-0
No files found.
app/controllers/admin/users_controller.rb
View file @
4caaea82
...
...
@@ -29,7 +29,7 @@ class Admin::UsersController < Admin::ApplicationController
def
new
@admin_user
=
User
.
new
({
projects_limit:
Gitlab
.
config
.
gitlab
.
default_projects_limit
},
as: :admin
)
@admin_user
=
User
.
new
.
with_defaults
end
def
edit
...
...
app/controllers/registrations_controller.rb
View file @
4caaea82
...
...
@@ -16,8 +16,7 @@ class RegistrationsController < Devise::RegistrationsController
def
build_resource
(
hash
=
nil
)
super
self
.
resource
.
projects_limit
=
Gitlab
.
config
.
gitlab
.
default_projects_limit
self
.
resource
self
.
resource
.
with_defaults
end
private
...
...
app/models/user.rb
View file @
4caaea82
...
...
@@ -196,6 +196,14 @@ class User < ActiveRecord::Base
username
end
def
with_defaults
tap
do
|
u
|
u
.
projects_limit
=
Gitlab
.
config
.
gitlab
.
default_projects_limit
u
.
can_create_group
=
Gitlab
.
config
.
gitlab
.
default_can_create_group
u
.
can_create_team
=
Gitlab
.
config
.
gitlab
.
default_can_create_team
end
end
def
notification
@notification
||=
Notification
.
new
(
self
)
end
...
...
config/gitlab.yml.example
View file @
4caaea82
...
...
@@ -32,12 +32,14 @@ production: &base
# Email address of your support contact (default: same as email_from)
support_email: support@localhost
##
Project
settings
##
User
settings
default_projects_limit: 10
# default_can_create_group: false # default: true
# default_can_create_team: false # default: true
# username_changing_enabled: false # default: true - User can change her username/namespace
## Users management
# signup_enabled: true # default: false - Account passwords are not sent via the email if signup is enabled.
# username_changing_enabled: false # default: true - User can change her username/namespace
## Default project features settings
default_projects_features:
...
...
config/initializers/1_settings.rb
View file @
4caaea82
...
...
@@ -48,7 +48,9 @@ Settings['issues_tracker'] ||= {}
# GitLab
#
Settings
[
'gitlab'
]
||=
Settingslogic
.
new
({})
Settings
.
gitlab
[
'default_projects_limit'
]
||=
10
Settings
.
gitlab
[
'default_projects_limit'
]
||=
10
Settings
.
gitlab
[
'default_can_create_group'
]
=
true
if
Settings
.
gitlab
[
'default_can_create_group'
].
nil?
Settings
.
gitlab
[
'default_can_create_team'
]
=
true
if
Settings
.
gitlab
[
'default_can_create_team'
].
nil?
Settings
.
gitlab
[
'host'
]
||=
'localhost'
Settings
.
gitlab
[
'https'
]
=
false
if
Settings
.
gitlab
[
'https'
].
nil?
Settings
.
gitlab
[
'port'
]
||=
Settings
.
gitlab
.
https
?
443
:
80
...
...
@@ -111,3 +113,12 @@ Settings.satellites['path'] = File.expand_path(Settings.satellites['path'] || "t
# Extra customization
#
Settings
[
'extra'
]
||=
Settingslogic
.
new
({})
#
# Testing settings
#
if
Rails
.
env
.
test?
Settings
.
gitlab
[
'default_projects_limit'
]
=
42
Settings
.
gitlab
[
'default_can_create_group'
]
=
false
Settings
.
gitlab
[
'default_can_create_team'
]
=
false
end
lib/gitlab/auth.rb
View file @
4caaea82
...
...
@@ -39,8 +39,7 @@ module Gitlab
email:
email
,
password:
password
,
password_confirmation:
password
,
projects_limit:
Gitlab
.
config
.
gitlab
.
default_projects_limit
,
},
as: :admin
)
},
as: :admin
).
with_defaults
@user
.
save!
if
Gitlab
.
config
.
omniauth
[
'block_auto_created_users'
]
&&
!
ldap
...
...
spec/features/admin/admin_users_spec.rb
View file @
4caaea82
...
...
@@ -33,6 +33,14 @@ describe "Admin::Users" do
expect
{
click_button
"Create user"
}.
to
change
{
User
.
count
}.
by
(
1
)
end
it
"should apply defaults to user"
do
click_button
"Create user"
user
=
User
.
last
user
.
projects_limit
.
should
==
Gitlab
.
config
.
gitlab
.
default_projects_limit
user
.
can_create_group
.
should
==
Gitlab
.
config
.
gitlab
.
default_can_create_group
user
.
can_create_team
.
should
==
Gitlab
.
config
.
gitlab
.
default_can_create_team
end
it
"should create user with valid data"
do
click_button
"Create user"
user
=
User
.
last
...
...
spec/lib/auth_spec.rb
View file @
4caaea82
...
...
@@ -91,5 +91,15 @@ describe Gitlab::Auth do
user
.
extern_uid
.
should
==
@info
.
uid
user
.
provider
.
should
==
'twitter'
end
it
"should apply defaults to user"
do
@auth
=
mock
(
info:
@info
,
provider:
'ldap'
)
user
=
gl_auth
.
create_from_omniauth
(
@auth
,
true
)
user
.
should
be_valid
user
.
projects_limit
.
should
==
Gitlab
.
config
.
gitlab
.
default_projects_limit
user
.
can_create_group
.
should
==
Gitlab
.
config
.
gitlab
.
default_can_create_group
user
.
can_create_team
.
should
==
Gitlab
.
config
.
gitlab
.
default_can_create_team
end
end
end
spec/models/user_spec.rb
View file @
4caaea82
...
...
@@ -178,4 +178,22 @@ describe User do
it
{
user
.
can_create_project?
.
should
be_true
}
it
{
user
.
first_name
.
should
==
'John'
}
end
describe
'without defaults'
do
let
(
:user
)
{
User
.
new
}
it
"should not apply defaults to user"
do
user
.
projects_limit
.
should
==
10
user
.
can_create_group
.
should
==
true
user
.
can_create_team
.
should
==
true
end
end
describe
'with defaults'
do
let
(
:user
)
{
User
.
new
.
with_defaults
}
it
"should apply defaults to user"
do
user
.
projects_limit
.
should
==
42
user
.
can_create_group
.
should
==
false
user
.
can_create_team
.
should
==
false
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment