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
Léo-Paul Géneau
gitlab-ce
Commits
c89e5784
Commit
c89e5784
authored
Jun 01, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use shared examples for populate spec
parent
c418d687
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
20 deletions
+18
-20
spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb
spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb
+16
-18
spec/support/shared_examples/models/atomic_internal_id_spec.rb
...support/shared_examples/models/atomic_internal_id_spec.rb
+2
-2
No files found.
spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb
View file @
c89e5784
...
@@ -157,6 +157,16 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do
...
@@ -157,6 +157,16 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do
end
end
context
'when variables policy is specified'
do
context
'when variables policy is specified'
do
shared_examples_for
'populates pipeline according to used policies'
do
it
'populates pipeline according to used policies'
do
step
.
perform!
expect
(
pipeline
.
stages
.
size
).
to
eq
1
expect
(
pipeline
.
stages
.
first
.
builds
.
size
).
to
eq
1
expect
(
pipeline
.
stages
.
first
.
builds
.
first
.
name
).
to
eq
'rspec'
end
end
context
'when using only/except build policies'
do
context
'when using only/except build policies'
do
let
(
:config
)
do
let
(
:config
)
do
{
rspec:
{
script:
'rspec'
,
stage:
'test'
,
only:
[
'master'
]
},
{
rspec:
{
script:
'rspec'
,
stage:
'test'
,
only:
[
'master'
]
},
...
@@ -167,28 +177,16 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do
...
@@ -167,28 +177,16 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do
build
(
:ci_pipeline
,
ref:
'master'
,
config:
config
)
build
(
:ci_pipeline
,
ref:
'master'
,
config:
config
)
end
end
it
'populates pipeline according to used policies'
do
it_behaves_like
'populates pipeline according to used policies'
step
.
perform!
expect
(
pipeline
.
stages
.
size
).
to
eq
1
expect
(
pipeline
.
stages
.
first
.
builds
.
size
).
to
eq
1
expect
(
pipeline
.
stages
.
first
.
builds
.
first
.
name
).
to
eq
'rspec'
end
context
'when variables expression is specified'
do
context
'when variables expression is specified'
do
context
'when pipeline iid is the subject'
do
let
(
:config
)
do
let
(
:config
)
do
{
rspec:
{
script:
'rspec'
,
only:
{
variables:
[
"$CI_PIPELINE_IID == '1'"
]
}
},
{
rspec:
{
script:
'rspec'
,
only:
{
variables:
[
"$CI_PIPELINE_IID == '1'"
]
}
},
prod:
{
script:
'cap prod'
,
only:
{
variables:
[
"$CI_PIPELINE_IID == '1000'"
]
}
}
}
prod:
{
script:
'cap prod'
,
only:
{
variables:
[
"$CI_PIPELINE_IID == '1000'"
]
}
}
}
end
end
context
'when pipeline iid is the subject'
do
it_behaves_like
'populates pipeline according to used policies'
it
'populates pipeline according to used policies'
do
step
.
perform!
expect
(
pipeline
.
stages
.
size
).
to
eq
1
expect
(
pipeline
.
stages
.
first
.
builds
.
size
).
to
eq
1
expect
(
pipeline
.
stages
.
first
.
builds
.
first
.
name
).
to
eq
'rspec'
end
end
end
end
end
end
end
...
...
spec/support/shared_examples/models/atomic_internal_id_spec.rb
View file @
c89e5784
...
@@ -15,7 +15,7 @@ shared_examples_for 'AtomicInternalId' do |validate_presence: true|
...
@@ -15,7 +15,7 @@ shared_examples_for 'AtomicInternalId' do |validate_presence: true|
instance
.
valid?
instance
.
valid?
end
end
context
'when presence validat
t
ion is required'
do
context
'when presence validation is required'
do
before
do
before
do
skip
unless
validate_presence
skip
unless
validate_presence
end
end
...
@@ -25,7 +25,7 @@ shared_examples_for 'AtomicInternalId' do |validate_presence: true|
...
@@ -25,7 +25,7 @@ shared_examples_for 'AtomicInternalId' do |validate_presence: true|
end
end
end
end
context
'when presence validat
t
ion is not required'
do
context
'when presence validation is not required'
do
before
do
before
do
skip
if
validate_presence
skip
if
validate_presence
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