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
740ee583
Commit
740ee583
authored
Oct 02, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make it possible to specifiy only: changes keywords
parent
14909330
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
3 deletions
+23
-3
lib/gitlab/ci/config/entry/policy.rb
lib/gitlab/ci/config/entry/policy.rb
+4
-2
spec/lib/gitlab/ci/config/entry/policy_spec.rb
spec/lib/gitlab/ci/config/entry/policy_spec.rb
+19
-1
No files found.
lib/gitlab/ci/config/entry/policy.rb
View file @
740ee583
...
...
@@ -25,17 +25,19 @@ module Gitlab
include
Entry
::
Validatable
include
Entry
::
Attributable
attributes
:refs
,
:kubernetes
,
:variables
ALLOWED_KEYS
=
%i[refs kubernetes variables changes]
attributes
:refs
,
:kubernetes
,
:variables
,
:changes
validations
do
validates
:config
,
presence:
true
validates
:config
,
allowed_keys:
%i[refs kubernetes variables]
validates
:config
,
allowed_keys:
ALLOWED_KEYS
validate
:variables_expressions_syntax
with_options
allow_nil:
true
do
validates
:refs
,
array_of_strings_or_regexps:
true
validates
:kubernetes
,
allowed_values:
%w[active]
validates
:variables
,
array_of_strings:
true
validates
:changes
,
array_of_strings:
true
end
def
variables_expressions_syntax
...
...
spec/lib/gitlab/ci/config/entry/policy_spec.rb
View file @
740ee583
require
'spec_helper'
require
'fast_spec_helper'
require_dependency
'active_model'
describe
Gitlab
::
Ci
::
Config
::
Entry
::
Policy
do
let
(
:entry
)
{
described_class
.
new
(
config
)
}
...
...
@@ -124,6 +125,23 @@ describe Gitlab::Ci::Config::Entry::Policy do
end
end
context
'when specifying a valid changes policy'
do
let
(
:config
)
{
{
changes:
%w[some/* paths/**/*.rb]
}
}
it
'is a correct configuraton'
do
expect
(
entry
).
to
be_valid
expect
(
entry
.
value
).
to
eq
(
config
)
end
end
context
'when changes policy is invalid'
do
let
(
:config
)
{
{
changes:
[
1
,
2
]
}
}
it
'returns errors'
do
expect
(
entry
.
errors
).
to
include
/changes should be an array of strings/
end
end
context
'when specifying unknown policy'
do
let
(
:config
)
{
{
refs:
[
'master'
],
invalid: :something
}
}
...
...
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