Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
a8f87197a2b3
Commit
a8f87197
authored
Jul 12, 2018
by
Grzegorz Bizon
Browse files
Improve project build time setting validation
parent
15ee9989fad5
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/models/project.rb
View file @
a8f87197
...
...
@@ -368,8 +368,10 @@
chronic_duration_attr
:build_timeout_human_readable
,
:build_timeout
,
default:
3600
validates
:build_timeout
,
allow_nil:
true
,
numericality:
{
greater_than_or_equal_to:
600
,
message:
'needs to be at least 10 minutes'
}
numericality:
{
greater_than_or_equal_to:
10
.
minutes
,
less_than:
1
.
month
,
only_integer:
true
,
message:
'needs to be beetween 10 minutes and 1 month'
}
# Returns a collection of projects that is either public or visible to the
# logged in user.
...
...
spec/models/project_spec.rb
View file @
a8f87197
...
...
@@ -149,6 +149,5 @@
it
{
is_expected
.
to
validate_presence_of
(
:name
)
}
it
{
is_expected
.
to
validate_uniqueness_of
(
:name
).
scoped_to
(
:namespace_id
)
}
it
{
is_expected
.
to
validate_length_of
(
:name
).
is_at_most
(
255
)
}
it
{
is_expected
.
to
validate_presence_of
(
:path
)
}
it
{
is_expected
.
to
validate_length_of
(
:path
).
is_at_most
(
255
)
}
...
...
@@ -153,4 +152,3 @@
it
{
is_expected
.
to
validate_presence_of
(
:path
)
}
it
{
is_expected
.
to
validate_length_of
(
:path
).
is_at_most
(
255
)
}
it
{
is_expected
.
to
validate_length_of
(
:description
).
is_at_most
(
2000
)
}
...
...
@@ -156,6 +154,5 @@
it
{
is_expected
.
to
validate_length_of
(
:description
).
is_at_most
(
2000
)
}
it
{
is_expected
.
to
validate_length_of
(
:ci_config_path
).
is_at_most
(
255
)
}
it
{
is_expected
.
to
allow_value
(
''
).
for
(
:ci_config_path
)
}
it
{
is_expected
.
not_to
allow_value
(
'test/../foo'
).
for
(
:ci_config_path
)
}
it
{
is_expected
.
not_to
allow_value
(
'/test/foo'
).
for
(
:ci_config_path
)
}
...
...
@@ -158,6 +155,5 @@
it
{
is_expected
.
to
validate_length_of
(
:ci_config_path
).
is_at_most
(
255
)
}
it
{
is_expected
.
to
allow_value
(
''
).
for
(
:ci_config_path
)
}
it
{
is_expected
.
not_to
allow_value
(
'test/../foo'
).
for
(
:ci_config_path
)
}
it
{
is_expected
.
not_to
allow_value
(
'/test/foo'
).
for
(
:ci_config_path
)
}
it
{
is_expected
.
to
validate_presence_of
(
:creator
)
}
...
...
@@ -163,3 +159,2 @@
it
{
is_expected
.
to
validate_presence_of
(
:creator
)
}
it
{
is_expected
.
to
validate_presence_of
(
:namespace
)
}
...
...
@@ -165,4 +160,3 @@
it
{
is_expected
.
to
validate_presence_of
(
:namespace
)
}
it
{
is_expected
.
to
validate_presence_of
(
:repository_storage
)
}
...
...
@@ -167,5 +161,13 @@
it
{
is_expected
.
to
validate_presence_of
(
:repository_storage
)
}
it
'validates build timeout constraints'
do
is_expected
.
to
validate_numericality_of
(
:build_timeout
)
.
only_integer
.
is_greater_than_or_equal_to
(
10
.
minutes
)
.
is_less_than
(
1
.
month
)
.
with_message
(
'needs to be beetween 10 minutes and 1 month'
)
end
it
'does not allow new projects beyond user limits'
do
project2
=
build
(
:project
)
allow
(
project2
).
to
receive
(
:creator
).
and_return
(
double
(
can_create_project?:
false
,
projects_limit:
0
).
as_null_object
)
...
...
Write
Preview
Supports
Markdown
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