BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
a04cbd5b
Commit
a04cbd5b
authored
Sep 15, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for CI/CD job policy refs specification
parent
97caed20
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
88 additions
and
1 deletion
+88
-1
refs.rb
lib/gitlab/ci/build/policy/refs.rb
+1
-1
refs_spec.rb
spec/lib/gitlab/ci/build/policy/refs_spec.rb
+87
-0
No files found.
lib/gitlab/ci/build/policy/refs.rb
View file @
a04cbd5b
...
...
@@ -7,7 +7,7 @@ module Gitlab
@patterns
=
Array
(
refs
)
end
def
satisfied_by?
(
pipeline
,
path
:)
def
satisfied_by?
(
pipeline
,
path:
nil
)
@patterns
.
any?
do
|
pattern
|
pattern
,
ref_path
=
pattern
.
split
(
'@'
,
2
)
...
...
spec/lib/gitlab/ci/build/policy/refs_spec.rb
0 → 100644
View file @
a04cbd5b
require
'spec_helper'
describe
Gitlab
::
Ci
::
Build
::
Policy
::
Refs
do
describe
'#satisfied_by?'
do
context
'when matching ref'
do
let
(
:pipeline
)
{
build_stubbed
(
:ci_pipeline
,
ref:
'master'
)
}
it
'is satisfied when pipeline branch matches'
do
expect
(
described_class
.
new
(
%w[master deploy]
))
.
to
be_satisfied_by
(
pipeline
)
end
it
'is not satisfied when pipeline branch does not match'
do
expect
(
described_class
.
new
(
%w[feature fix]
))
.
not_to
be_satisfied_by
(
pipeline
)
end
end
context
'when maching tags'
do
context
'when pipeline runs for a tag'
do
let
(
:pipeline
)
do
build_stubbed
(
:ci_pipeline
,
ref:
'feature'
,
tag:
true
)
end
it
'is satisfied when tags matcher is specified'
do
expect
(
described_class
.
new
(
%w[master tags]
))
.
to
be_satisfied_by
(
pipeline
)
end
end
context
'when pipeline is not created for a tag'
do
let
(
:pipeline
)
do
build_stubbed
(
:ci_pipeline
,
ref:
'feature'
,
tag:
false
)
end
it
'is not satisfied when tag match is specified'
do
expect
(
described_class
.
new
(
%w[master tags]
))
.
not_to
be_satisfied_by
(
pipeline
)
end
end
end
context
'when also matching a path'
do
let
(
:pipeline
)
do
build_stubbed
(
:ci_pipeline
,
ref:
'master'
)
end
it
'is satisfied when provided patch matches specified one'
do
expect
(
described_class
.
new
(
%w[master@some/repository]
))
.
to
be_satisfied_by
(
pipeline
,
path:
'some/repository'
)
end
it
'is not satisfied when path differs'
do
expect
(
described_class
.
new
(
%w[master@some/fork/repository]
))
.
not_to
be_satisfied_by
(
pipeline
,
path:
'some/repository'
)
end
end
context
'when maching a source'
do
let
(
:pipeline
)
{
build_stubbed
(
:ci_pipeline
,
source: :push
)
}
it
'is satisifed when provided source keyword matches'
do
expect
(
described_class
.
new
(
%w[pushes]
))
.
to
be_satisfied_by
(
pipeline
)
end
it
'is not satisfied when provided source keyword does not match'
do
expect
(
described_class
.
new
(
%w[triggers]
))
.
not_to
be_satisfied_by
(
pipeline
)
end
end
context
'when matching a ref by a regular expression'
do
let
(
:pipeline
)
{
build_stubbed
(
:ci_pipeline
,
ref:
'docs-something'
)
}
it
'is satisfied when regexp matches pipeline ref'
do
expect
(
described_class
.
new
([
'/docs-.*/'
]))
.
to
be_satisfied_by
(
pipeline
)
end
it
'is not satisfied when regexp does not match pipeline ref'
do
expect
(
described_class
.
new
([
'/fix-.*/'
]))
.
not_to
be_satisfied_by
(
pipeline
)
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