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
Léo-Paul Géneau
gitlab-ce
Commits
035196e7
Commit
035196e7
authored
Oct 09, 2011
by
gitlabhq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test fix
parent
67f0c62d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
3 deletions
+12
-3
app/controllers/admin/projects_controller.rb
app/controllers/admin/projects_controller.rb
+1
-0
app/models/project.rb
app/models/project.rb
+8
-2
db/schema.rb
db/schema.rb
+1
-1
spec/factories.rb
spec/factories.rb
+2
-0
No files found.
app/controllers/admin/projects_controller.rb
View file @
035196e7
...
@@ -35,6 +35,7 @@ class Admin::ProjectsController < ApplicationController
...
@@ -35,6 +35,7 @@ class Admin::ProjectsController < ApplicationController
def
create
def
create
@admin_project
=
Project
.
new
(
params
[
:project
])
@admin_project
=
Project
.
new
(
params
[
:project
])
@admin_project
.
owner
=
current_user
respond_to
do
|
format
|
respond_to
do
|
format
|
if
@admin_project
.
save
if
@admin_project
.
save
...
...
app/models/project.rb
View file @
035196e7
require
"grit"
require
"grit"
class
Project
<
ActiveRecord
::
Base
class
Project
<
ActiveRecord
::
Base
belongs_to
:owner
,
:class_name
=>
"User"
has_many
:issues
,
:dependent
=>
:destroy
has_many
:issues
,
:dependent
=>
:destroy
has_many
:users_projects
,
:dependent
=>
:destroy
has_many
:users_projects
,
:dependent
=>
:destroy
has_many
:users
,
:through
=>
:users_projects
has_many
:users
,
:through
=>
:users_projects
belongs_to
:owner
,
:class_name
=>
"User"
has_many
:notes
,
:dependent
=>
:destroy
has_many
:notes
,
:dependent
=>
:destroy
validates
:name
,
validates
:name
,
...
@@ -25,6 +26,9 @@ class Project < ActiveRecord::Base
...
@@ -25,6 +26,9 @@ class Project < ActiveRecord::Base
:uniqueness
=>
true
,
:uniqueness
=>
true
,
:length
=>
{
:within
=>
3
..
12
}
:length
=>
{
:within
=>
3
..
12
}
validates
:owner
,
:presence
=>
true
validate
:check_limit
validate
:check_limit
before_save
:format_code
before_save
:format_code
...
@@ -130,8 +134,10 @@ class Project < ActiveRecord::Base
...
@@ -130,8 +134,10 @@ class Project < ActiveRecord::Base
def
check_limit
def
check_limit
unless
owner
.
can_create_project?
unless
owner
.
can_create_project?
errors
[
:base
]
<<
(
"You
can to have
#{
owner
.
projects_limit
}
your own projects
"
)
errors
[
:base
]
<<
(
"You
r own projects limit is
#{
owner
.
projects_limit
}
! Please contact administrator to increase it
"
)
end
end
rescue
errors
[
:base
]
<<
(
"Cant check your ability to create project"
)
end
end
def
valid_repo?
def
valid_repo?
...
...
db/schema.rb
View file @
035196e7
...
@@ -70,7 +70,7 @@ ActiveRecord::Schema.define(:version => 20111009111204) do
...
@@ -70,7 +70,7 @@ ActiveRecord::Schema.define(:version => 20111009111204) do
t
.
datetime
"updated_at"
t
.
datetime
"updated_at"
t
.
string
"name"
t
.
string
"name"
t
.
boolean
"admin"
,
:default
=>
false
,
:null
=>
false
t
.
boolean
"admin"
,
:default
=>
false
,
:null
=>
false
t
.
integer
"projects_limit"
t
.
integer
"projects_limit"
,
:default
=>
10
end
end
add_index
"users"
,
[
"email"
],
:name
=>
"index_users_on_email"
,
:unique
=>
true
add_index
"users"
,
[
"email"
],
:name
=>
"index_users_on_email"
,
:unique
=>
true
...
...
spec/factories.rb
View file @
035196e7
...
@@ -3,6 +3,7 @@ require File.join(Rails.root, 'spec', 'factory')
...
@@ -3,6 +3,7 @@ require File.join(Rails.root, 'spec', 'factory')
Factory
.
add
(
:project
,
Project
)
do
|
obj
|
Factory
.
add
(
:project
,
Project
)
do
|
obj
|
obj
.
name
=
Faker
::
Internet
.
user_name
obj
.
name
=
Faker
::
Internet
.
user_name
obj
.
path
=
'legit'
obj
.
path
=
'legit'
obj
.
owner
=
Factory
(
:user
)
obj
.
code
=
'LGT'
obj
.
code
=
'LGT'
end
end
...
@@ -10,6 +11,7 @@ Factory.add(:public_project, Project) do |obj|
...
@@ -10,6 +11,7 @@ Factory.add(:public_project, Project) do |obj|
obj
.
name
=
Faker
::
Internet
.
user_name
obj
.
name
=
Faker
::
Internet
.
user_name
obj
.
path
=
'legit'
obj
.
path
=
'legit'
obj
.
private_flag
=
false
obj
.
private_flag
=
false
obj
.
owner
=
Factory
(
:user
)
obj
.
code
=
'LGT'
obj
.
code
=
'LGT'
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