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
0ea8c236
Commit
0ea8c236
authored
Jan 14, 2019
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more specs for only/except policy config entry
parent
67e90a12
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
3 deletions
+51
-3
lib/gitlab/ci/config/entry/policy.rb
lib/gitlab/ci/config/entry/policy.rb
+1
-1
spec/lib/gitlab/ci/config/entry/policy_spec.rb
spec/lib/gitlab/ci/config/entry/policy_spec.rb
+50
-2
No files found.
lib/gitlab/ci/config/entry/policy.rb
View file @
0ea8c236
...
@@ -65,7 +65,7 @@ module Gitlab
...
@@ -65,7 +65,7 @@ module Gitlab
end
end
def
value
def
value
self
.
class
.
default
(
key:
@key
).
yield_self
do
|
default
|
self
.
class
.
default
(
key:
@
subject
.
key
).
yield_self
do
|
default
|
default
.
to_h
.
deep_merge
(
@subject
.
value
.
to_h
)
default
.
to_h
.
deep_merge
(
@subject
.
value
.
to_h
)
end
end
end
end
...
...
spec/lib/gitlab/ci/config/entry/policy_spec.rb
View file @
0ea8c236
...
@@ -168,9 +168,57 @@ describe Gitlab::Ci::Config::Entry::Policy do
...
@@ -168,9 +168,57 @@ describe Gitlab::Ci::Config::Entry::Policy do
end
end
end
end
describe
'#value'
do
context
'when it is `only` policy'
do
before
do
entry
.
key
=
:only
end
context
'when user overrides default values'
do
let
(
:config
)
{
{
refs:
%w[feature]
,
variables:
%w[$VARIABLE]
}
}
it
'does not include default values'
do
expect
(
entry
.
value
).
to
eq
config
end
end
context
'when user does not override default values'
do
let
(
:config
)
{
{
variables:
%w[$VARIABLE]
}
}
it
'includes default values'
do
expect
(
entry
.
value
).
to
eq
(
refs:
%w[branches tags]
,
variables:
%w[$VARIABLE]
)
end
end
end
context
'when it is `except` policy'
do
before
do
entry
.
key
=
:except
end
context
'when user does not override default values'
do
let
(
:config
)
{
{
variables:
%w[$VARIABLE]
}
}
it
'does not include default values'
do
expect
(
entry
.
value
).
to
eq
config
end
end
end
end
describe
'.default'
do
describe
'.default'
do
it
'does not have a default value'
do
context
'when `only` policy is about to be fabricated'
do
expect
(
described_class
.
default
).
to
be_nil
it
'has a default value'
do
expect
(
described_class
.
default
(
key: :only
))
.
to
eq
(
refs:
%w[branches tags]
)
end
end
context
'when `except` policy is about to be fabricated'
do
it
'does not have a default value'
do
expect
(
described_class
.
default
(
key: :except
)).
to
be_nil
end
end
end
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