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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
bd08cac8
Commit
bd08cac8
authored
Oct 15, 2011
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
project path & code regexp validation
parent
82f79d71
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
9 additions
and
10 deletions
+9
-10
app/models/project.rb
app/models/project.rb
+5
-6
config/initializers/rails_footnotes.rb
config/initializers/rails_footnotes.rb
+1
-1
config/routes.rb
config/routes.rb
+1
-1
spec/requests/admin/admin_projects_spec.rb
spec/requests/admin/admin_projects_spec.rb
+1
-1
spec/requests/projects_spec.rb
spec/requests/projects_spec.rb
+1
-1
No files found.
app/models/project.rb
View file @
bd08cac8
...
@@ -16,6 +16,8 @@ class Project < ActiveRecord::Base
...
@@ -16,6 +16,8 @@ class Project < ActiveRecord::Base
validates
:path
,
validates
:path
,
:uniqueness
=>
true
,
:uniqueness
=>
true
,
:presence
=>
true
,
:presence
=>
true
,
:format
=>
{
:with
=>
/^[a-zA-Z0-9_\-]*$/
,
:message
=>
"only letters, digits & '_' '-' allowed"
},
:length
=>
{
:within
=>
0
..
255
}
:length
=>
{
:within
=>
0
..
255
}
validates
:description
,
validates
:description
,
...
@@ -24,14 +26,15 @@ class Project < ActiveRecord::Base
...
@@ -24,14 +26,15 @@ class Project < ActiveRecord::Base
validates
:code
,
validates
:code
,
:presence
=>
true
,
:presence
=>
true
,
:uniqueness
=>
true
,
:uniqueness
=>
true
,
:length
=>
{
:within
=>
3
..
12
}
:format
=>
{
:with
=>
/^[a-zA-Z0-9_\-]*$/
,
:message
=>
"only letters, digits & '_' '-' allowed"
},
:length
=>
{
:within
=>
3
..
16
}
validates
:owner
,
validates
:owner
,
:presence
=>
true
:presence
=>
true
validate
:check_limit
validate
:check_limit
before_save
:format_code
after_destroy
:destroy_gitosis_project
after_destroy
:destroy_gitosis_project
after_save
:update_gitosis_project
after_save
:update_gitosis_project
...
@@ -47,10 +50,6 @@ class Project < ActiveRecord::Base
...
@@ -47,10 +50,6 @@ class Project < ActiveRecord::Base
notes
.
where
(
:noteable_type
=>
[
""
,
nil
])
notes
.
where
(
:noteable_type
=>
[
""
,
nil
])
end
end
def
format_code
read_attribute
(
:code
).
downcase
.
strip
.
gsub
(
' '
,
''
)
end
def
update_gitosis_project
def
update_gitosis_project
Gitosis
.
new
.
configure
do
|
c
|
Gitosis
.
new
.
configure
do
|
c
|
c
.
update_project
(
path
,
gitosis_writers
)
c
.
update_project
(
path
,
gitosis_writers
)
...
...
config/initializers/rails_footnotes.rb
View file @
bd08cac8
if
defined?
(
Footnotes
)
&&
Rails
.
env
.
development?
if
defined?
(
Footnotes
)
&&
Rails
.
env
.
development?
Footnotes
.
run!
# first of all
#
Footnotes.run! # first of all
# ... other init code
# ... other init code
end
end
config/routes.rb
View file @
bd08cac8
...
@@ -32,7 +32,7 @@ Gitlab::Application.routes.draw do
...
@@ -32,7 +32,7 @@ Gitlab::Application.routes.draw do
get
"tree/:commit_id/:path"
=>
"projects#tree"
,
get
"tree/:commit_id/:path"
=>
"projects#tree"
,
:as
=>
:tree_file
,
:as
=>
:tree_file
,
:constraints
=>
{
:constraints
=>
{
:id
=>
/[a-zA-Z0-9]+/
,
:id
=>
/[a-zA-Z0-9
_\-
]+/
,
:commit_id
=>
/[a-zA-Z0-9]+/
,
:commit_id
=>
/[a-zA-Z0-9]+/
,
:path
=>
/.*/
:path
=>
/.*/
}
}
...
...
spec/requests/admin/admin_projects_spec.rb
View file @
bd08cac8
...
@@ -88,7 +88,7 @@ describe "Admin::Projects" do
...
@@ -88,7 +88,7 @@ describe "Admin::Projects" do
visit
new_admin_project_path
visit
new_admin_project_path
fill_in
'Name'
,
:with
=>
'NewProject'
fill_in
'Name'
,
:with
=>
'NewProject'
fill_in
'Code'
,
:with
=>
'NPR'
fill_in
'Code'
,
:with
=>
'NPR'
fill_in
'Path'
,
:with
=>
'
/tmp/legit_test/legit
'
fill_in
'Path'
,
:with
=>
'
legit_1
'
expect
{
click_button
"Save"
}.
to
change
{
Project
.
count
}.
by
(
1
)
expect
{
click_button
"Save"
}.
to
change
{
Project
.
count
}.
by
(
1
)
@project
=
Project
.
last
@project
=
Project
.
last
end
end
...
...
spec/requests/projects_spec.rb
View file @
bd08cac8
...
@@ -39,7 +39,7 @@ describe "Projects" do
...
@@ -39,7 +39,7 @@ describe "Projects" do
visit
new_project_path
visit
new_project_path
fill_in
'Name'
,
:with
=>
'NewProject'
fill_in
'Name'
,
:with
=>
'NewProject'
fill_in
'Code'
,
:with
=>
'NPR'
fill_in
'Code'
,
:with
=>
'NPR'
fill_in
'Path'
,
:with
=>
'
/tmp/legit_test/legi
t'
fill_in
'Path'
,
:with
=>
'
newprojec
t'
expect
{
click_button
"Create Project"
}.
to
change
{
Project
.
count
}.
by
(
1
)
expect
{
click_button
"Create Project"
}.
to
change
{
Project
.
count
}.
by
(
1
)
@project
=
Project
.
last
@project
=
Project
.
last
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