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
7f392ed0
Commit
7f392ed0
authored
Mar 02, 2022
by
Martin LEHOUX
Committed by
Shinya Maeda
Mar 02, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use the same duration limit in job and in rule
parent
93c65343
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
4 deletions
+14
-4
lib/gitlab/ci/config/entry/rules/rule.rb
lib/gitlab/ci/config/entry/rules/rule.rb
+1
-1
spec/lib/gitlab/ci/config/entry/rules/rule_spec.rb
spec/lib/gitlab/ci/config/entry/rules/rule_spec.rb
+13
-3
No files found.
lib/gitlab/ci/config/entry/rules/rule.rb
View file @
7f392ed0
...
...
@@ -24,7 +24,7 @@ module Gitlab
validates
:config
,
allowed_keys:
ALLOWED_KEYS
validates
:config
,
disallowed_keys:
%i[start_in]
,
unless: :specifies_delay?
validates
:start_in
,
presence:
true
,
if: :specifies_delay?
validates
:start_in
,
duration:
{
limit:
'1
day
'
},
if: :specifies_delay?
validates
:start_in
,
duration:
{
limit:
'1
week
'
},
if: :specifies_delay?
with_options
allow_nil:
true
do
validates
:if
,
expression:
true
...
...
spec/lib/gitlab/ci/config/entry/rules/rule_spec.rb
View file @
7f392ed0
...
...
@@ -174,13 +174,13 @@ RSpec.describe Gitlab::Ci::Config::Entry::Rules::Rule do
end
context
'specifying a delayed job'
do
let
(
:config
)
{
{
if:
'$THIS || $THAT'
,
when:
'delayed'
,
start_in:
'
15 minute
s'
}
}
let
(
:config
)
{
{
if:
'$THIS || $THAT'
,
when:
'delayed'
,
start_in:
'
2 day
s'
}
}
it
{
is_expected
.
to
be_valid
}
it
'sets attributes for the job delay'
do
expect
(
entry
.
when
).
to
eq
(
'delayed'
)
expect
(
entry
.
start_in
).
to
eq
(
'
15 minute
s'
)
expect
(
entry
.
start_in
).
to
eq
(
'
2 day
s'
)
end
context
'without a when: key'
do
...
...
@@ -198,10 +198,20 @@ RSpec.describe Gitlab::Ci::Config::Entry::Rules::Rule do
it
{
is_expected
.
not_to
be_valid
}
it
'returns an error about
t
start_in being blank'
do
it
'returns an error about start_in being blank'
do
expect
(
entry
.
errors
).
to
include
(
/start in can't be blank/
)
end
end
context
'when start_in value is longer than a week'
do
let
(
:config
)
{
{
if:
'$THIS || $THAT'
,
when:
'delayed'
,
start_in:
'2 weeks'
}
}
it
{
is_expected
.
not_to
be_valid
}
it
'returns an error about start_in exceeding the limit'
do
expect
(
entry
.
errors
).
to
include
(
/start in should not exceed the limit/
)
end
end
end
context
'when specifying unknown policy'
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