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
Boxiang Sun
gitlab-ce
Commits
eee454e1
Commit
eee454e1
authored
Sep 27, 2018
by
Shinya Maeda
Committed by
Alessio Caiazza
Oct 02, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix validation methods in Config::Entry::Job. Added spec for that
parent
6fb1e0d8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
9 deletions
+69
-9
lib/gitlab/ci/config/entry/job.rb
lib/gitlab/ci/config/entry/job.rb
+4
-9
spec/lib/gitlab/ci/config/entry/job_spec.rb
spec/lib/gitlab/ci/config/entry/job_spec.rb
+65
-0
No files found.
lib/gitlab/ci/config/entry/job.rb
View file @
eee454e1
...
@@ -30,19 +30,14 @@ module Gitlab
...
@@ -30,19 +30,14 @@ module Gitlab
validates
:when
,
validates
:when
,
inclusion:
{
in:
%w[on_success on_failure always manual delayed]
,
inclusion:
{
in:
%w[on_success on_failure always manual delayed]
,
message:
'should be on_success, on_failure, '
\
message:
'should be on_success, on_failure, '
\
'always
or manual
'
}
'always
, manual or delayed
'
}
validates
:dependencies
,
array_of_strings:
true
validates
:dependencies
,
array_of_strings:
true
validates
:extends
,
type:
String
validates
:extends
,
type:
String
with_options
if: :delayed?
do
validates
:start_in
,
duration:
true
,
allow_nil:
false
end
end
with_options
unless: :delayed?
do
validates
:start_in
,
duration:
true
,
if: :delayed?
validates
:start_in
,
presence:
false
validates
:start_in
,
absence:
true
,
unless: :delayed?
end
end
end
end
entry
:before_script
,
Entry
::
Script
,
entry
:before_script
,
Entry
::
Script
,
...
...
spec/lib/gitlab/ci/config/entry/job_spec.rb
View file @
eee454e1
...
@@ -39,6 +39,16 @@ describe Gitlab::Ci::Config::Entry::Job do
...
@@ -39,6 +39,16 @@ describe Gitlab::Ci::Config::Entry::Job do
expect
(
entry
.
errors
).
to
include
"job name can't be blank"
expect
(
entry
.
errors
).
to
include
"job name can't be blank"
end
end
end
end
context
'when delayed job'
do
context
'when start_in is specified'
do
let
(
:config
)
{
{
script:
'echo'
,
when:
'delayed'
,
start_in:
'1 day'
}
}
it
'returns error about invalid type'
do
expect
(
entry
).
to
be_valid
end
end
end
end
end
context
'when entry value is not correct'
do
context
'when entry value is not correct'
do
...
@@ -129,6 +139,43 @@ describe Gitlab::Ci::Config::Entry::Job do
...
@@ -129,6 +139,43 @@ describe Gitlab::Ci::Config::Entry::Job do
end
end
end
end
end
end
context
'when delayed job'
do
context
'when start_in is specified'
do
let
(
:config
)
{
{
script:
'echo'
,
when:
'delayed'
,
start_in:
'1 day'
}
}
it
'returns error about invalid type'
do
expect
(
entry
).
to
be_valid
end
end
context
'when start_in is empty'
do
let
(
:config
)
{
{
when:
'delayed'
,
start_in:
nil
}
}
it
'returns error about invalid type'
do
expect
(
entry
).
not_to
be_valid
expect
(
entry
.
errors
).
to
include
'job start in should be a duration'
end
end
context
'when start_in is not formateed ad a duration'
do
let
(
:config
)
{
{
when:
'delayed'
,
start_in:
'test'
}
}
it
'returns error about invalid type'
do
expect
(
entry
).
not_to
be_valid
expect
(
entry
.
errors
).
to
include
'job start in should be a duration'
end
end
end
context
'when start_in specified without delayed specification'
do
let
(
:config
)
{
{
start_in:
'1 day'
}
}
it
'returns error about invalid type'
do
expect
(
entry
).
not_to
be_valid
expect
(
entry
.
errors
).
to
include
'job start in must be blank'
end
end
end
end
end
end
...
@@ -238,6 +285,24 @@ describe Gitlab::Ci::Config::Entry::Job do
...
@@ -238,6 +285,24 @@ describe Gitlab::Ci::Config::Entry::Job do
end
end
end
end
describe
'#delayed?'
do
context
'when job is a delayed'
do
let
(
:config
)
{
{
script:
'deploy'
,
when:
'delayed'
}
}
it
'is a delayed'
do
expect
(
entry
).
to
be_delayed
end
end
context
'when job is not a delayed'
do
let
(
:config
)
{
{
script:
'deploy'
}
}
it
'is not a delayed'
do
expect
(
entry
).
not_to
be_delayed
end
end
end
describe
'#ignored?'
do
describe
'#ignored?'
do
context
'when job is a manual action'
do
context
'when job is a manual action'
do
context
'when it is not specified if job is allowed to fail'
do
context
'when it is not specified if job is allowed to fail'
do
...
...
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