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
7825830c
Commit
7825830c
authored
Aug 13, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow project name, path etc start with number. Fixed specs
parent
a36195bd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
10 deletions
+11
-10
app/models/project.rb
app/models/project.rb
+2
-2
lib/gitlab/regex.rb
lib/gitlab/regex.rb
+2
-2
spec/models/commit_spec.rb
spec/models/commit_spec.rb
+3
-3
spec/models/project_spec.rb
spec/models/project_spec.rb
+4
-3
No files found.
app/models/project.rb
View file @
7825830c
...
@@ -73,11 +73,11 @@ class Project < ActiveRecord::Base
...
@@ -73,11 +73,11 @@ class Project < ActiveRecord::Base
validates
:description
,
length:
{
within:
0
..
2000
}
validates
:description
,
length:
{
within:
0
..
2000
}
validates
:name
,
presence:
true
,
length:
{
within:
0
..
255
},
validates
:name
,
presence:
true
,
length:
{
within:
0
..
255
},
format:
{
with:
Gitlab
::
Regex
.
project_name_regex
,
format:
{
with:
Gitlab
::
Regex
.
project_name_regex
,
message:
"only letters, digits, spaces & '_' '-' '.' allowed. Letter should be first"
}
message:
"only letters, digits, spaces & '_' '-' '.' allowed. Letter
or digit
should be first"
}
validates
:path
,
presence:
true
,
length:
{
within:
0
..
255
},
validates
:path
,
presence:
true
,
length:
{
within:
0
..
255
},
exclusion:
{
in:
Gitlab
::
Blacklist
.
path
},
exclusion:
{
in:
Gitlab
::
Blacklist
.
path
},
format:
{
with:
Gitlab
::
Regex
.
path_regex
,
format:
{
with:
Gitlab
::
Regex
.
path_regex
,
message:
"only letters, digits & '_' '-' '.' allowed. Letter should be first"
}
message:
"only letters, digits & '_' '-' '.' allowed. Letter
or digit
should be first"
}
validates
:issues_enabled
,
:wall_enabled
,
:merge_requests_enabled
,
validates
:issues_enabled
,
:wall_enabled
,
:merge_requests_enabled
,
:wiki_enabled
,
inclusion:
{
in:
[
true
,
false
]
}
:wiki_enabled
,
inclusion:
{
in:
[
true
,
false
]
}
validates
:issues_tracker_id
,
length:
{
within:
0
..
255
}
validates
:issues_tracker_id
,
length:
{
within:
0
..
255
}
...
...
lib/gitlab/regex.rb
View file @
7825830c
...
@@ -7,7 +7,7 @@ module Gitlab
...
@@ -7,7 +7,7 @@ module Gitlab
end
end
def
project_name_regex
def
project_name_regex
/\A[a-zA-Z][a-zA-Z0-9_\-\. ]*\z/
/\A[a-zA-Z
0-9
][a-zA-Z0-9_\-\. ]*\z/
end
end
def
name_regex
def
name_regex
...
@@ -21,7 +21,7 @@ module Gitlab
...
@@ -21,7 +21,7 @@ module Gitlab
protected
protected
def
default_regex
def
default_regex
/\A[a-zA-Z][a-zA-Z0-9_\-\.]*\z/
/\A[a-zA-Z
0-9
][a-zA-Z0-9_\-\.]*\z/
end
end
end
end
end
end
spec/models/commit_spec.rb
View file @
7825830c
...
@@ -9,11 +9,11 @@ describe Commit do
...
@@ -9,11 +9,11 @@ describe Commit do
commit
.
title
.
should
==
"--no commit message"
commit
.
title
.
should
==
"--no commit message"
end
end
it
"truncates a message without a newline at
7
0 characters"
do
it
"truncates a message without a newline at
8
0 characters"
do
message
=
commit
.
safe_message
*
10
message
=
commit
.
safe_message
*
10
commit
.
stub
(
:safe_message
).
and_return
(
message
)
commit
.
stub
(
:safe_message
).
and_return
(
message
)
commit
.
title
.
should
==
"
#{
message
[
0
..
6
9
]
}
…"
commit
.
title
.
should
==
"
#{
message
[
0
..
7
9
]
}
…"
end
end
it
"truncates a message with a newline before 80 characters at the newline"
do
it
"truncates a message with a newline before 80 characters at the newline"
do
...
@@ -27,7 +27,7 @@ describe Commit do
...
@@ -27,7 +27,7 @@ describe Commit do
message
=
(
commit
.
safe_message
*
10
)
+
"
\n
"
message
=
(
commit
.
safe_message
*
10
)
+
"
\n
"
commit
.
stub
(
:safe_message
).
and_return
(
message
)
commit
.
stub
(
:safe_message
).
and_return
(
message
)
commit
.
title
.
should
==
"
#{
message
[
0
..
6
9
]
}
…"
commit
.
title
.
should
==
"
#{
message
[
0
..
7
9
]
}
…"
end
end
end
end
...
...
spec/models/project_spec.rb
View file @
7825830c
...
@@ -68,9 +68,10 @@ describe Project do
...
@@ -68,9 +68,10 @@ describe Project do
it
{
should
ensure_length_of
(
:issues_tracker_id
).
is_within
(
0
..
255
)
}
it
{
should
ensure_length_of
(
:issues_tracker_id
).
is_within
(
0
..
255
)
}
it
"should not allow new projects beyond user limits"
do
it
"should not allow new projects beyond user limits"
do
project
.
stub
(
:creator
).
and_return
(
double
(
can_create_project?:
false
,
projects_limit:
1
))
project2
=
build
(
:project
)
project
.
should_not
be_valid
project2
.
stub
(
:creator
).
and_return
(
double
(
can_create_project?:
false
,
projects_limit:
0
))
project
.
errors
[
:limit_reached
].
first
.
should
match
(
/Your own projects limit is 1/
)
project2
.
should_not
be_valid
project2
.
errors
[
:limit_reached
].
first
.
should
match
(
/Your own projects limit is 0/
)
end
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