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
d8d45553
Commit
d8d45553
authored
Feb 09, 2021
by
Allison Browne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Speed up pipeline model specs
51.1960s -> 34.8263s
parent
a68e88e7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
212 additions
and
138 deletions
+212
-138
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+212
-138
No files found.
spec/models/ci/pipeline_spec.rb
View file @
d8d45553
...
@@ -11,10 +11,6 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -11,10 +11,6 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
let_it_be
(
:namespace
)
{
create_default
(
:namespace
).
freeze
}
let_it_be
(
:namespace
)
{
create_default
(
:namespace
).
freeze
}
let_it_be
(
:project
)
{
create_default
(
:project
,
:repository
).
freeze
}
let_it_be
(
:project
)
{
create_default
(
:project
,
:repository
).
freeze
}
let
(
:pipeline
)
do
create
(
:ci_empty_pipeline
,
status: :created
,
project:
project
)
end
it_behaves_like
'having unique enum values'
it_behaves_like
'having unique enum values'
it
{
is_expected
.
to
belong_to
(
:project
)
}
it
{
is_expected
.
to
belong_to
(
:project
)
}
...
@@ -53,6 +49,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -53,6 +49,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'associations'
do
describe
'associations'
do
let_it_be
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
status: :created
,
project:
project
)
}
it
'has a bidirectional relationship with projects'
do
it
'has a bidirectional relationship with projects'
do
expect
(
described_class
.
reflect_on_association
(
:project
).
has_inverse?
).
to
eq
(
:all_pipelines
)
expect
(
described_class
.
reflect_on_association
(
:project
).
has_inverse?
).
to
eq
(
:all_pipelines
)
expect
(
Project
.
reflect_on_association
(
:all_pipelines
).
has_inverse?
).
to
eq
(
:project
)
expect
(
Project
.
reflect_on_association
(
:all_pipelines
).
has_inverse?
).
to
eq
(
:project
)
...
@@ -82,6 +80,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -82,6 +80,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'#set_status'
do
describe
'#set_status'
do
let
(
:pipeline
)
{
build
(
:ci_empty_pipeline
,
status: :created
,
project:
project
)
}
where
(
:from_status
,
:to_status
)
do
where
(
:from_status
,
:to_status
)
do
from_status_names
=
described_class
.
state_machines
[
:status
].
states
.
map
(
&
:name
)
from_status_names
=
described_class
.
state_machines
[
:status
].
states
.
map
(
&
:name
)
to_status_names
=
from_status_names
-
[
:created
]
# we never want to transition into created
to_status_names
=
from_status_names
-
[
:created
]
# we never want to transition into created
...
@@ -105,6 +105,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -105,6 +105,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'.processables'
do
describe
'.processables'
do
let_it_be
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
status: :created
,
project:
project
)
}
before
do
before
do
create
(
:ci_build
,
name:
'build'
,
pipeline:
pipeline
)
create
(
:ci_build
,
name:
'build'
,
pipeline:
pipeline
)
create
(
:ci_bridge
,
name:
'bridge'
,
pipeline:
pipeline
)
create
(
:ci_bridge
,
name:
'bridge'
,
pipeline:
pipeline
)
...
@@ -247,13 +249,16 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -247,13 +249,16 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
describe
'.ci_sources'
do
describe
'.ci_sources'
do
subject
{
described_class
.
ci_sources
}
subject
{
described_class
.
ci_sources
}
let!
(
:push_pipeline
)
{
create
(
:ci_pipeline
,
source: :push
)
}
let!
(
:push_pipeline
)
{
build
(
:ci_pipeline
,
source: :push
)
}
let!
(
:web_pipeline
)
{
create
(
:ci_pipeline
,
source: :web
)
}
let!
(
:web_pipeline
)
{
build
(
:ci_pipeline
,
source: :web
)
}
let!
(
:api_pipeline
)
{
create
(
:ci_pipeline
,
source: :api
)
}
let!
(
:api_pipeline
)
{
build
(
:ci_pipeline
,
source: :api
)
}
let!
(
:webide_pipeline
)
{
create
(
:ci_pipeline
,
source: :webide
)
}
let!
(
:webide_pipeline
)
{
build
(
:ci_pipeline
,
source: :webide
)
}
let!
(
:child_pipeline
)
{
create
(
:ci_pipeline
,
source: :parent_pipeline
)
}
let!
(
:child_pipeline
)
{
build
(
:ci_pipeline
,
source: :parent_pipeline
)
}
let
(
:pipelines
)
{
[
push_pipeline
,
web_pipeline
,
api_pipeline
,
webide_pipeline
,
child_pipeline
]
}
it
'contains pipelines having CI only sources'
do
it
'contains pipelines having CI only sources'
do
pipelines
.
map
(
&
:save
)
expect
(
subject
).
to
contain_exactly
(
push_pipeline
,
web_pipeline
,
api_pipeline
)
expect
(
subject
).
to
contain_exactly
(
push_pipeline
,
web_pipeline
,
api_pipeline
)
end
end
...
@@ -387,6 +392,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -387,6 +392,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
describe
'#merge_request_ref?'
do
describe
'#merge_request_ref?'
do
subject
{
pipeline
.
merge_request_ref?
}
subject
{
pipeline
.
merge_request_ref?
}
let
(
:pipeline
)
{
build
(
:ci_empty_pipeline
,
status: :created
,
project:
project
)
}
it
'calls MergeRequest#merge_request_ref?'
do
it
'calls MergeRequest#merge_request_ref?'
do
expect
(
MergeRequest
).
to
receive
(
:merge_request_ref?
).
with
(
pipeline
.
ref
)
expect
(
MergeRequest
).
to
receive
(
:merge_request_ref?
).
with
(
pipeline
.
ref
)
...
@@ -633,17 +640,21 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -633,17 +640,21 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
context
'when updating existing pipeline'
do
context
'when updating existing pipeline'
do
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
status: :created
,
project:
project
)
}
before
do
before
do
pipeline
.
update_attribute
(
:source
,
nil
)
pipeline
.
update_attribute
(
:source
,
nil
)
end
end
it
"object is valid"
do
it
'object is valid'
do
expect
(
pipeline
).
to
be_valid
expect
(
pipeline
).
to
be_valid
end
end
end
end
end
end
describe
'#block'
do
describe
'#block'
do
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
status: :created
,
project:
project
)
}
it
'changes pipeline status to manual'
do
it
'changes pipeline status to manual'
do
expect
(
pipeline
.
block
).
to
be
true
expect
(
pipeline
.
block
).
to
be
true
expect
(
pipeline
.
reload
).
to
be_manual
expect
(
pipeline
.
reload
).
to
be_manual
...
@@ -664,6 +675,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -664,6 +675,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'#valid_commit_sha'
do
describe
'#valid_commit_sha'
do
let
(
:pipeline
)
{
build_stubbed
(
:ci_empty_pipeline
,
status: :created
,
project:
project
)
}
context
'commit.sha can not start with 00000000'
do
context
'commit.sha can not start with 00000000'
do
before
do
before
do
pipeline
.
sha
=
'0'
*
40
pipeline
.
sha
=
'0'
*
40
...
@@ -677,6 +690,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -677,6 +690,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
describe
'#short_sha'
do
describe
'#short_sha'
do
subject
{
pipeline
.
short_sha
}
subject
{
pipeline
.
short_sha
}
let
(
:pipeline
)
{
build_stubbed
(
:ci_empty_pipeline
,
status: :created
,
project:
project
)
}
it
'has 8 items'
do
it
'has 8 items'
do
expect
(
subject
.
size
).
to
eq
(
8
)
expect
(
subject
.
size
).
to
eq
(
8
)
end
end
...
@@ -686,6 +701,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -686,6 +701,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
describe
'#retried'
do
describe
'#retried'
do
subject
{
pipeline
.
retried
}
subject
{
pipeline
.
retried
}
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
status: :created
,
project:
project
)
}
before
do
before
do
@build1
=
create
(
:ci_build
,
pipeline:
pipeline
,
name:
'deploy'
,
retried:
true
)
@build1
=
create
(
:ci_build
,
pipeline:
pipeline
,
name:
'deploy'
,
retried:
true
)
@build2
=
create
(
:ci_build
,
pipeline:
pipeline
,
name:
'deploy'
)
@build2
=
create
(
:ci_build
,
pipeline:
pipeline
,
name:
'deploy'
)
...
@@ -697,8 +714,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -697,8 +714,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'#coverage'
do
describe
'#coverage'
do
let
(
:project
)
{
create
(
:project
,
build_coverage_regex:
"/.*/"
)
}
let
_it_be
(
:project
)
{
create
(
:project
,
build_coverage_regex:
"/.*/"
)
}
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
project:
project
)
}
let
_it_be_with_reload
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
project:
project
)
}
it
"calculates average when there are two builds with coverage"
do
it
"calculates average when there are two builds with coverage"
do
create
(
:ci_build
,
name:
"rspec"
,
coverage:
30
,
pipeline:
pipeline
)
create
(
:ci_build
,
name:
"rspec"
,
coverage:
30
,
pipeline:
pipeline
)
...
@@ -729,6 +746,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -729,6 +746,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
describe
'#retryable?'
do
describe
'#retryable?'
do
subject
{
pipeline
.
retryable?
}
subject
{
pipeline
.
retryable?
}
let_it_be
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
status: :created
,
project:
project
)
}
context
'no failed builds'
do
context
'no failed builds'
do
before
do
before
do
create_build
(
'rspec'
,
'success'
)
create_build
(
'rspec'
,
'success'
)
...
@@ -790,6 +809,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -790,6 +809,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
describe
'#predefined_variables'
do
describe
'#predefined_variables'
do
subject
{
pipeline
.
predefined_variables
}
subject
{
pipeline
.
predefined_variables
}
let
(
:pipeline
)
{
build
(
:ci_empty_pipeline
,
status: :created
,
project:
project
)
}
it
'includes all predefined variables in a valid order'
do
it
'includes all predefined variables in a valid order'
do
keys
=
subject
.
map
{
|
variable
|
variable
[
:key
]
}
keys
=
subject
.
map
{
|
variable
|
variable
[
:key
]
}
...
@@ -816,21 +837,18 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -816,21 +837,18 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
context
'when merge request is present'
do
context
'when merge request is present'
do
let_it_be
(
:assignees
)
{
create_list
(
:user
,
2
)
}
let_it_be
(
:milestone
)
{
create
(
:milestone
,
project:
project
)
}
let_it_be
(
:labels
)
{
create_list
(
:label
,
2
)
}
let
(
:merge_request
)
do
let
(
:merge_request
)
do
create
(
:merge_request
,
create
(
:merge_request
,
:simple
,
source_project:
project
,
source_project:
project
,
source_branch:
'feature'
,
target_project:
project
,
target_project:
project
,
target_branch:
'master'
,
assignees:
assignees
,
assignees:
assignees
,
milestone:
milestone
,
milestone:
milestone
,
labels:
labels
)
labels:
labels
)
end
end
let
(
:assignees
)
{
create_list
(
:user
,
2
)
}
let
(
:milestone
)
{
create
(
:milestone
,
project:
project
)
}
let
(
:labels
)
{
create_list
(
:label
,
2
)
}
context
'when pipeline for merge request is created'
do
context
'when pipeline for merge request is created'
do
let
(
:pipeline
)
do
let
(
:pipeline
)
do
create
(
:ci_pipeline
,
:detached_merge_request_pipeline
,
create
(
:ci_pipeline
,
:detached_merge_request_pipeline
,
...
@@ -1016,6 +1034,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -1016,6 +1034,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'#protected_ref?'
do
describe
'#protected_ref?'
do
let
(
:pipeline
)
{
build
(
:ci_empty_pipeline
,
status: :created
,
project:
project
)
}
before
do
before
do
pipeline
.
project
=
create
(
:project
,
:repository
)
pipeline
.
project
=
create
(
:project
,
:repository
)
end
end
...
@@ -1027,6 +1047,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -1027,6 +1047,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
describe
'#legacy_trigger'
do
describe
'#legacy_trigger'
do
let
(
:trigger_request
)
{
create
(
:ci_trigger_request
)
}
let
(
:trigger_request
)
{
create
(
:ci_trigger_request
)
}
let
(
:pipeline
)
{
build
(
:ci_empty_pipeline
,
status: :created
,
project:
project
)
}
before
do
before
do
pipeline
.
trigger_requests
<<
trigger_request
pipeline
.
trigger_requests
<<
trigger_request
...
@@ -1040,6 +1061,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -1040,6 +1061,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
describe
'#auto_canceled?'
do
describe
'#auto_canceled?'
do
subject
{
pipeline
.
auto_canceled?
}
subject
{
pipeline
.
auto_canceled?
}
let
(
:pipeline
)
{
build
(
:ci_empty_pipeline
,
status: :created
,
project:
project
)
}
context
'when it is canceled'
do
context
'when it is canceled'
do
before
do
before
do
pipeline
.
cancel
pipeline
.
cancel
...
@@ -1075,6 +1098,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -1075,6 +1098,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'pipeline stages'
do
describe
'pipeline stages'
do
let
(
:pipeline
)
{
build
(
:ci_empty_pipeline
,
status: :created
,
project:
project
)
}
describe
'legacy stages'
do
describe
'legacy stages'
do
before
do
before
do
create
(
:commit_status
,
pipeline:
pipeline
,
create
(
:commit_status
,
pipeline:
pipeline
,
...
@@ -1180,6 +1205,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -1180,6 +1205,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
describe
'#legacy_stage'
do
describe
'#legacy_stage'
do
subject
{
pipeline
.
legacy_stage
(
'test'
)
}
subject
{
pipeline
.
legacy_stage
(
'test'
)
}
let
(
:pipeline
)
{
build
(
:ci_empty_pipeline
,
status: :created
,
project:
project
)
}
context
'with status in stage'
do
context
'with status in stage'
do
before
do
before
do
create
(
:commit_status
,
pipeline:
pipeline
,
stage:
'test'
)
create
(
:commit_status
,
pipeline:
pipeline
,
stage:
'test'
)
...
@@ -1202,6 +1229,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -1202,6 +1229,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'#stages'
do
describe
'#stages'
do
let
(
:pipeline
)
{
build
(
:ci_empty_pipeline
,
status: :created
,
project:
project
)
}
before
do
before
do
create
(
:ci_stage_entity
,
project:
project
,
create
(
:ci_stage_entity
,
project:
project
,
pipeline:
pipeline
,
pipeline:
pipeline
,
...
@@ -1256,6 +1285,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -1256,6 +1285,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'state machine'
do
describe
'state machine'
do
let_it_be_with_reload
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
status: :created
,
project:
project
)
}
let
(
:current
)
{
Time
.
current
.
change
(
usec:
0
)
}
let
(
:current
)
{
Time
.
current
.
change
(
usec:
0
)
}
let
(
:build
)
{
create_build
(
'build1'
,
queued_at:
0
)
}
let
(
:build
)
{
create_build
(
'build1'
,
queued_at:
0
)
}
let
(
:build_b
)
{
create_build
(
'build2'
,
queued_at:
0
)
}
let
(
:build_b
)
{
create_build
(
'build2'
,
queued_at:
0
)
}
...
@@ -1459,15 +1489,15 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -1459,15 +1489,15 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'auto merge'
do
describe
'auto merge'
do
let
(
:merge_request
)
{
create
(
:merge_request
,
:merge_when_pipeline_succeeds
)
}
context
'when auto merge is enabled'
do
let_it_be_with_reload
(
:merge_request
)
{
create
(
:merge_request
,
:merge_when_pipeline_succeeds
)
}
let
(
:pipeline
)
do
let_it_be_with_reload
(
:pipeline
)
do
create
(
:ci_pipeline
,
:running
,
project:
merge_request
.
source_project
,
create
(
:ci_pipeline
,
:running
,
project:
merge_request
.
source_project
,
ref:
merge_request
.
source_branch
,
ref:
merge_request
.
source_branch
,
sha:
merge_request
.
diff_head_sha
)
sha:
merge_request
.
diff_head_sha
)
end
end
before
do
before_all
do
merge_request
.
update_head_pipeline
merge_request
.
update_head_pipeline
end
end
...
@@ -1480,6 +1510,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -1480,6 +1510,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
end
end
end
end
end
context
'when auto merge is not enabled in the merge request'
do
context
'when auto merge is not enabled in the merge request'
do
let
(
:merge_request
)
{
create
(
:merge_request
)
}
let
(
:merge_request
)
{
create
(
:merge_request
)
}
...
@@ -1655,6 +1686,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -1655,6 +1686,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
describe
'#branch?'
do
describe
'#branch?'
do
subject
{
pipeline
.
branch?
}
subject
{
pipeline
.
branch?
}
let
(
:pipeline
)
{
build
(
:ci_empty_pipeline
,
status: :created
,
project:
project
)
}
context
'when ref is not a tag'
do
context
'when ref is not a tag'
do
before
do
before
do
pipeline
.
tag
=
false
pipeline
.
tag
=
false
...
@@ -1665,16 +1698,12 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -1665,16 +1698,12 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
context
'when pipeline is merge request'
do
context
'when pipeline is merge request'
do
let
(
:pipeline
)
do
let
(
:pipeline
)
{
build
(
:ci_pipeline
,
merge_request:
merge_request
)
}
create
(
:ci_pipeline
,
merge_request:
merge_request
)
end
let
(
:merge_request
)
do
let
(
:merge_request
)
do
create
(
:merge_request
,
create
(
:merge_request
,
:simple
,
source_project:
project
,
source_project:
project
,
source_branch:
'feature'
,
target_project:
project
)
target_project:
project
,
target_branch:
'master'
)
end
end
it
'returns false'
do
it
'returns false'
do
...
@@ -1845,6 +1874,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -1845,6 +1874,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
describe
'#manual_actions'
do
describe
'#manual_actions'
do
subject
{
pipeline
.
manual_actions
}
subject
{
pipeline
.
manual_actions
}
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
status: :created
,
project:
project
)
}
it
'when none defined'
do
it
'when none defined'
do
is_expected
.
to
be_empty
is_expected
.
to
be_empty
end
end
...
@@ -1871,6 +1902,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -1871,6 +1902,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'#branch_updated?'
do
describe
'#branch_updated?'
do
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
status: :created
,
project:
project
)
}
context
'when pipeline has before SHA'
do
context
'when pipeline has before SHA'
do
before
do
before
do
pipeline
.
update_column
(
:before_sha
,
'a1b2c3d4'
)
pipeline
.
update_column
(
:before_sha
,
'a1b2c3d4'
)
...
@@ -1894,6 +1927,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -1894,6 +1927,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'#modified_paths'
do
describe
'#modified_paths'
do
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
status: :created
,
project:
project
)
}
context
'when old and new revisions are set'
do
context
'when old and new revisions are set'
do
before
do
before
do
pipeline
.
update!
(
before_sha:
'1234abcd'
,
sha:
'2345bcde'
)
pipeline
.
update!
(
before_sha:
'1234abcd'
,
sha:
'2345bcde'
)
...
@@ -1924,11 +1959,9 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -1924,11 +1959,9 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
let
(
:merge_request
)
do
let
(
:merge_request
)
do
create
(
:merge_request
,
create
(
:merge_request
,
:simple
,
source_project:
project
,
source_project:
project
,
source_branch:
'feature'
,
target_project:
project
)
target_project:
project
,
target_branch:
'master'
)
end
end
it
'returns merge request modified paths'
do
it
'returns merge request modified paths'
do
...
@@ -1962,6 +1995,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -1962,6 +1995,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'#has_kubernetes_active?'
do
describe
'#has_kubernetes_active?'
do
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
status: :created
,
project:
project
)
}
context
'when kubernetes is active'
do
context
'when kubernetes is active'
do
context
'when user configured kubernetes from CI/CD > Clusters'
do
context
'when user configured kubernetes from CI/CD > Clusters'
do
let!
(
:cluster
)
{
create
(
:cluster
,
:project
,
:provided_by_gcp
)
}
let!
(
:cluster
)
{
create
(
:cluster
,
:project
,
:provided_by_gcp
)
}
...
@@ -1983,6 +2018,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -1983,6 +2018,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
describe
'#has_warnings?'
do
describe
'#has_warnings?'
do
subject
{
pipeline
.
has_warnings?
}
subject
{
pipeline
.
has_warnings?
}
let_it_be
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
status: :created
,
project:
project
)
}
context
'build which is allowed to fail fails'
do
context
'build which is allowed to fail fails'
do
before
do
before
do
create
:ci_build
,
:success
,
pipeline:
pipeline
,
name:
'rspec'
create
:ci_build
,
:success
,
pipeline:
pipeline
,
name:
'rspec'
...
@@ -2039,6 +2076,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -2039,6 +2076,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'#number_of_warnings'
do
describe
'#number_of_warnings'
do
let_it_be
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
status: :created
,
project:
project
)
}
it
'returns the number of warnings'
do
it
'returns the number of warnings'
do
create
(
:ci_build
,
:allowed_to_fail
,
:failed
,
pipeline:
pipeline
,
name:
'rubocop'
)
create
(
:ci_build
,
:allowed_to_fail
,
:failed
,
pipeline:
pipeline
,
name:
'rubocop'
)
create
(
:ci_bridge
,
:allowed_to_fail
,
:failed
,
pipeline:
pipeline
,
name:
'rubocop'
)
create
(
:ci_bridge
,
:allowed_to_fail
,
:failed
,
pipeline:
pipeline
,
name:
'rubocop'
)
...
@@ -2071,6 +2110,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -2071,6 +2110,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
subject
{
pipeline
.
needs_processing?
}
subject
{
pipeline
.
needs_processing?
}
let_it_be
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
status: :created
,
project:
project
)
}
where
(
:processed
,
:result
)
do
where
(
:processed
,
:result
)
do
nil
|
true
nil
|
true
false
|
true
false
|
true
...
@@ -2090,8 +2131,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -2090,8 +2131,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
end
end
shared_context
'with some
outdated pipelines'
do
context
'with
outdated pipelines'
do
before
do
before
_all
do
create_pipeline
(
:canceled
,
'ref'
,
'A'
,
project
)
create_pipeline
(
:canceled
,
'ref'
,
'A'
,
project
)
create_pipeline
(
:success
,
'ref'
,
'A'
,
project
)
create_pipeline
(
:success
,
'ref'
,
'A'
,
project
)
create_pipeline
(
:failed
,
'ref'
,
'B'
,
project
)
create_pipeline
(
:failed
,
'ref'
,
'B'
,
project
)
...
@@ -2107,11 +2148,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -2107,11 +2148,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
project:
project
project:
project
)
)
end
end
end
describe
'.newest_first'
do
describe
'.newest_first'
do
include_context
'with some outdated pipelines'
it
'returns the pipelines from new to old'
do
it
'returns the pipelines from new to old'
do
expect
(
described_class
.
newest_first
.
pluck
(
:status
))
expect
(
described_class
.
newest_first
.
pluck
(
:status
))
.
to
eq
(
%w[skipped failed success canceled]
)
.
to
eq
(
%w[skipped failed success canceled]
)
...
@@ -2124,8 +2162,6 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -2124,8 +2162,6 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'.latest_status'
do
describe
'.latest_status'
do
include_context
'with some outdated pipelines'
context
'when no ref is specified'
do
context
'when no ref is specified'
do
it
'returns the status of the latest pipeline'
do
it
'returns the status of the latest pipeline'
do
expect
(
described_class
.
latest_status
).
to
eq
(
'skipped'
)
expect
(
described_class
.
latest_status
).
to
eq
(
'skipped'
)
...
@@ -2140,8 +2176,6 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -2140,8 +2176,6 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'.latest_successful_for_ref'
do
describe
'.latest_successful_for_ref'
do
include_context
'with some outdated pipelines'
let!
(
:latest_successful_pipeline
)
do
let!
(
:latest_successful_pipeline
)
do
create_pipeline
(
:success
,
'ref'
,
'D'
,
project
)
create_pipeline
(
:success
,
'ref'
,
'D'
,
project
)
end
end
...
@@ -2153,8 +2187,6 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -2153,8 +2187,6 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'.latest_running_for_ref'
do
describe
'.latest_running_for_ref'
do
include_context
'with some outdated pipelines'
let!
(
:latest_running_pipeline
)
do
let!
(
:latest_running_pipeline
)
do
create_pipeline
(
:running
,
'ref'
,
'D'
,
project
)
create_pipeline
(
:running
,
'ref'
,
'D'
,
project
)
end
end
...
@@ -2166,8 +2198,6 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -2166,8 +2198,6 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'.latest_failed_for_ref'
do
describe
'.latest_failed_for_ref'
do
include_context
'with some outdated pipelines'
let!
(
:latest_failed_pipeline
)
do
let!
(
:latest_failed_pipeline
)
do
create_pipeline
(
:failed
,
'ref'
,
'D'
,
project
)
create_pipeline
(
:failed
,
'ref'
,
'D'
,
project
)
end
end
...
@@ -2179,8 +2209,6 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -2179,8 +2209,6 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'.latest_successful_for_sha'
do
describe
'.latest_successful_for_sha'
do
include_context
'with some outdated pipelines'
let!
(
:latest_successful_pipeline
)
do
let!
(
:latest_successful_pipeline
)
do
create_pipeline
(
:success
,
'ref'
,
'awesomesha'
,
project
)
create_pipeline
(
:success
,
'ref'
,
'awesomesha'
,
project
)
end
end
...
@@ -2192,8 +2220,6 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -2192,8 +2220,6 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'.latest_successful_for_refs'
do
describe
'.latest_successful_for_refs'
do
include_context
'with some outdated pipelines'
let!
(
:latest_successful_pipeline1
)
do
let!
(
:latest_successful_pipeline1
)
do
create_pipeline
(
:success
,
'ref1'
,
'D'
,
project
)
create_pipeline
(
:success
,
'ref1'
,
'D'
,
project
)
end
end
...
@@ -2208,6 +2234,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -2208,6 +2234,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
expect
(
described_class
.
latest_successful_for_refs
(
refs
)).
to
eq
({
'ref1'
=>
latest_successful_pipeline1
,
'ref2'
=>
latest_successful_pipeline2
})
expect
(
described_class
.
latest_successful_for_refs
(
refs
)).
to
eq
({
'ref1'
=>
latest_successful_pipeline1
,
'ref2'
=>
latest_successful_pipeline2
})
end
end
end
end
end
describe
'.latest_pipeline_per_commit'
do
describe
'.latest_pipeline_per_commit'
do
let!
(
:commit_123_ref_master
)
do
let!
(
:commit_123_ref_master
)
do
...
@@ -2333,12 +2360,11 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -2333,12 +2360,11 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'#status'
,
:sidekiq_inline
do
describe
'#status'
,
:sidekiq_inline
do
let
(
:build
)
do
create
(
:ci_build
,
:created
,
pipeline:
pipeline
,
name:
'test'
)
end
subject
{
pipeline
.
reload
.
status
}
subject
{
pipeline
.
reload
.
status
}
let_it_be
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
status: :created
,
project:
project
)
}
let
(
:build
)
{
create
(
:ci_build
,
:created
,
pipeline:
pipeline
,
name:
'test'
)
}
context
'on waiting for resource'
do
context
'on waiting for resource'
do
before
do
before
do
allow
(
build
).
to
receive
(
:with_resource_group?
)
{
true
}
allow
(
build
).
to
receive
(
:with_resource_group?
)
{
true
}
...
@@ -2430,6 +2456,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -2430,6 +2456,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
describe
'#detailed_status'
do
describe
'#detailed_status'
do
subject
{
pipeline
.
detailed_status
(
user
)
}
subject
{
pipeline
.
detailed_status
(
user
)
}
let_it_be
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
status: :created
,
project:
project
)
}
context
'when pipeline is created'
do
context
'when pipeline is created'
do
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
status: :created
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
status: :created
)
}
...
@@ -2508,6 +2536,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -2508,6 +2536,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'#cancelable?'
do
describe
'#cancelable?'
do
let_it_be
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
status: :created
,
project:
project
)
}
%i[created running pending]
.
each
do
|
status0
|
%i[created running pending]
.
each
do
|
status0
|
context
"when there is a build
#{
status0
}
"
do
context
"when there is a build
#{
status0
}
"
do
before
do
before
do
...
@@ -2599,7 +2629,9 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -2599,7 +2629,9 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'#cancel_running'
do
describe
'#cancel_running'
do
let
(
:latest_status
)
{
pipeline
.
statuses
.
pluck
(
:status
)
}
subject
(
:latest_status
)
{
pipeline
.
statuses
.
pluck
(
:status
)
}
let_it_be
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
status: :created
,
project:
project
)
}
context
'when there is a running external job and a regular job'
do
context
'when there is a running external job and a regular job'
do
before
do
before
do
...
@@ -2642,7 +2674,9 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -2642,7 +2674,9 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'#retry_failed'
do
describe
'#retry_failed'
do
let
(
:latest_status
)
{
pipeline
.
latest_statuses
.
pluck
(
:status
)
}
subject
(
:latest_status
)
{
pipeline
.
latest_statuses
.
pluck
(
:status
)
}
let_it_be
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
status: :created
,
project:
project
)
}
before
do
before
do
stub_not_protect_default_branch
stub_not_protect_default_branch
...
@@ -2691,6 +2725,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -2691,6 +2725,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'#execute_hooks'
do
describe
'#execute_hooks'
do
let_it_be
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
status: :created
,
project:
project
)
}
let!
(
:build_a
)
{
create_build
(
'a'
,
0
)
}
let!
(
:build_a
)
{
create_build
(
'a'
,
0
)
}
let!
(
:build_b
)
{
create_build
(
'b'
,
0
)
}
let!
(
:build_b
)
{
create_build
(
'b'
,
0
)
}
...
@@ -2807,7 +2842,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -2807,7 +2842,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
"#merge_requests_as_head_pipeline"
do
describe
"#merge_requests_as_head_pipeline"
do
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
status:
'created'
,
project:
project
,
ref:
'master'
,
sha:
'a288a022a53a5a944fae87bcec6efc87b7061808'
)
}
let
_it_be_with_reload
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
status:
'created'
,
project:
project
,
ref:
'master'
,
sha:
'a288a022a53a5a944fae87bcec6efc87b7061808'
)
}
it
"returns merge requests whose `diff_head_sha` matches the pipeline's SHA"
do
it
"returns merge requests whose `diff_head_sha` matches the pipeline's SHA"
do
allow_next_instance_of
(
MergeRequest
)
do
|
instance
|
allow_next_instance_of
(
MergeRequest
)
do
|
instance
|
...
@@ -2819,7 +2854,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -2819,7 +2854,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
it
"doesn't return merge requests whose source branch doesn't match the pipeline's ref"
do
it
"doesn't return merge requests whose source branch doesn't match the pipeline's ref"
do
create
(
:merge_request
,
source_project:
project
,
source_branch:
'feature'
,
target_branch:
'master'
)
create
(
:merge_request
,
:simple
,
source_project:
project
)
expect
(
pipeline
.
merge_requests_as_head_pipeline
).
to
be_empty
expect
(
pipeline
.
merge_requests_as_head_pipeline
).
to
be_empty
end
end
...
@@ -2835,7 +2870,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -2835,7 +2870,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'#all_merge_requests'
do
describe
'#all_merge_requests'
do
let
(
:project
)
{
create
(
:project
)
}
let_it_be_with_reload
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
status: :created
,
project:
project
)
}
shared_examples
'a method that returns all merge requests for a given pipeline'
do
shared_examples
'a method that returns all merge requests for a given pipeline'
do
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
status:
'created'
,
project:
pipeline_project
,
ref:
'master'
)
}
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
status:
'created'
,
project:
pipeline_project
,
ref:
'master'
)
}
...
@@ -3018,6 +3054,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -3018,6 +3054,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
describe
'#same_family_pipeline_ids'
do
describe
'#same_family_pipeline_ids'
do
subject
{
pipeline
.
same_family_pipeline_ids
.
map
(
&
:id
)
}
subject
{
pipeline
.
same_family_pipeline_ids
.
map
(
&
:id
)
}
let_it_be
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
status: :created
,
project:
project
)
}
context
'when pipeline is not child nor parent'
do
context
'when pipeline is not child nor parent'
do
it
'returns just the pipeline id'
do
it
'returns just the pipeline id'
do
expect
(
subject
).
to
contain_exactly
(
pipeline
.
id
)
expect
(
subject
).
to
contain_exactly
(
pipeline
.
id
)
...
@@ -3106,6 +3144,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -3106,6 +3144,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'#stuck?'
do
describe
'#stuck?'
do
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
status: :created
,
project:
project
)
}
before
do
before
do
create
(
:ci_build
,
:pending
,
pipeline:
pipeline
)
create
(
:ci_build
,
:pending
,
pipeline:
pipeline
)
end
end
...
@@ -3150,6 +3190,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -3150,6 +3190,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'#has_yaml_errors?'
do
describe
'#has_yaml_errors?'
do
let
(
:pipeline
)
{
build_stubbed
(
:ci_pipeline
)
}
context
'when yaml_errors is set'
do
context
'when yaml_errors is set'
do
before
do
before
do
pipeline
.
yaml_errors
=
'File not found'
pipeline
.
yaml_errors
=
'File not found'
...
@@ -3351,6 +3393,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -3351,6 +3393,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'#build_with_artifacts_in_self_and_descendants'
do
describe
'#build_with_artifacts_in_self_and_descendants'
do
let_it_be
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let!
(
:build
)
{
create
(
:ci_build
,
name:
'test'
,
pipeline:
pipeline
)
}
let!
(
:build
)
{
create
(
:ci_build
,
name:
'test'
,
pipeline:
pipeline
)
}
let
(
:child_pipeline
)
{
create
(
:ci_pipeline
,
child_of:
pipeline
)
}
let
(
:child_pipeline
)
{
create
(
:ci_pipeline
,
child_of:
pipeline
)
}
let!
(
:child_build
)
{
create
(
:ci_build
,
:artifacts
,
name:
'test'
,
pipeline:
child_pipeline
)
}
let!
(
:child_build
)
{
create
(
:ci_build
,
:artifacts
,
name:
'test'
,
pipeline:
child_pipeline
)
}
...
@@ -3369,6 +3412,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -3369,6 +3412,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'#find_job_with_archive_artifacts'
do
describe
'#find_job_with_archive_artifacts'
do
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let!
(
:old_job
)
{
create
(
:ci_build
,
name:
'rspec'
,
retried:
true
,
pipeline:
pipeline
)
}
let!
(
:old_job
)
{
create
(
:ci_build
,
name:
'rspec'
,
retried:
true
,
pipeline:
pipeline
)
}
let!
(
:job_without_artifacts
)
{
create
(
:ci_build
,
name:
'rspec'
,
pipeline:
pipeline
)
}
let!
(
:job_without_artifacts
)
{
create
(
:ci_build
,
name:
'rspec'
,
pipeline:
pipeline
)
}
let!
(
:expected_job
)
{
create
(
:ci_build
,
:artifacts
,
name:
'rspec'
,
pipeline:
pipeline
)
}
let!
(
:expected_job
)
{
create
(
:ci_build
,
:artifacts
,
name:
'rspec'
,
pipeline:
pipeline
)
}
...
@@ -3382,6 +3426,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -3382,6 +3426,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'#latest_builds_with_artifacts'
do
describe
'#latest_builds_with_artifacts'
do
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let!
(
:fresh_build
)
{
create
(
:ci_build
,
:success
,
:artifacts
,
pipeline:
pipeline
)
}
let!
(
:fresh_build
)
{
create
(
:ci_build
,
:success
,
:artifacts
,
pipeline:
pipeline
)
}
let!
(
:stale_build
)
{
create
(
:ci_build
,
:success
,
:expired
,
:artifacts
,
pipeline:
pipeline
)
}
let!
(
:stale_build
)
{
create
(
:ci_build
,
:success
,
:expired
,
:artifacts
,
pipeline:
pipeline
)
}
...
@@ -3417,6 +3462,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -3417,6 +3462,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'#latest_report_builds'
do
describe
'#latest_report_builds'
do
let_it_be
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
it
'returns build with test artifacts'
do
it
'returns build with test artifacts'
do
test_build
=
create
(
:ci_build
,
:test_reports
,
pipeline:
pipeline
,
project:
project
)
test_build
=
create
(
:ci_build
,
:test_reports
,
pipeline:
pipeline
,
project:
project
)
coverage_build
=
create
(
:ci_build
,
:coverage_reports
,
pipeline:
pipeline
,
project:
project
)
coverage_build
=
create
(
:ci_build
,
:coverage_reports
,
pipeline:
pipeline
,
project:
project
)
...
@@ -3593,9 +3640,9 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -3593,9 +3640,9 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
describe
'#test_report_summary'
do
describe
'#test_report_summary'
do
subject
{
pipeline
.
test_report_summary
}
subject
{
pipeline
.
test_report_summary
}
context
'when pipeline has multiple builds with report results'
do
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
:success
,
project:
project
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
:success
,
project:
project
)
}
context
'when pipeline has multiple builds with report results'
do
before
do
before
do
create
(
:ci_build
,
:success
,
:report_results
,
name:
'rspec'
,
pipeline:
pipeline
,
project:
project
)
create
(
:ci_build
,
:success
,
:report_results
,
name:
'rspec'
,
pipeline:
pipeline
,
project:
project
)
create
(
:ci_build
,
:success
,
:report_results
,
name:
'java'
,
pipeline:
pipeline
,
project:
project
)
create
(
:ci_build
,
:success
,
:report_results
,
name:
'java'
,
pipeline:
pipeline
,
project:
project
)
...
@@ -3616,6 +3663,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -3616,6 +3663,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
describe
'#test_reports'
do
describe
'#test_reports'
do
subject
{
pipeline
.
test_reports
}
subject
{
pipeline
.
test_reports
}
let_it_be
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
context
'when pipeline has multiple builds with test reports'
do
context
'when pipeline has multiple builds with test reports'
do
let!
(
:build_rspec
)
{
create
(
:ci_build
,
:success
,
name:
'rspec'
,
pipeline:
pipeline
,
project:
project
)
}
let!
(
:build_rspec
)
{
create
(
:ci_build
,
:success
,
name:
'rspec'
,
pipeline:
pipeline
,
project:
project
)
}
let!
(
:build_java
)
{
create
(
:ci_build
,
:success
,
name:
'java'
,
pipeline:
pipeline
,
project:
project
)
}
let!
(
:build_java
)
{
create
(
:ci_build
,
:success
,
name:
'java'
,
pipeline:
pipeline
,
project:
project
)
}
...
@@ -3653,6 +3702,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -3653,6 +3702,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
describe
'#accessibility_reports'
do
describe
'#accessibility_reports'
do
subject
{
pipeline
.
accessibility_reports
}
subject
{
pipeline
.
accessibility_reports
}
let_it_be
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
context
'when pipeline has multiple builds with accessibility reports'
do
context
'when pipeline has multiple builds with accessibility reports'
do
let
(
:build_rspec
)
{
create
(
:ci_build
,
:success
,
name:
'rspec'
,
pipeline:
pipeline
,
project:
project
)
}
let
(
:build_rspec
)
{
create
(
:ci_build
,
:success
,
name:
'rspec'
,
pipeline:
pipeline
,
project:
project
)
}
let
(
:build_golang
)
{
create
(
:ci_build
,
:success
,
name:
'golang'
,
pipeline:
pipeline
,
project:
project
)
}
let
(
:build_golang
)
{
create
(
:ci_build
,
:success
,
name:
'golang'
,
pipeline:
pipeline
,
project:
project
)
}
...
@@ -3689,6 +3740,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -3689,6 +3740,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
describe
'#coverage_reports'
do
describe
'#coverage_reports'
do
subject
{
pipeline
.
coverage_reports
}
subject
{
pipeline
.
coverage_reports
}
let_it_be
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
context
'when pipeline has multiple builds with coverage reports'
do
context
'when pipeline has multiple builds with coverage reports'
do
let!
(
:build_rspec
)
{
create
(
:ci_build
,
:success
,
name:
'rspec'
,
pipeline:
pipeline
,
project:
project
)
}
let!
(
:build_rspec
)
{
create
(
:ci_build
,
:success
,
name:
'rspec'
,
pipeline:
pipeline
,
project:
project
)
}
let!
(
:build_golang
)
{
create
(
:ci_build
,
:success
,
name:
'golang'
,
pipeline:
pipeline
,
project:
project
)
}
let!
(
:build_golang
)
{
create
(
:ci_build
,
:success
,
name:
'golang'
,
pipeline:
pipeline
,
project:
project
)
}
...
@@ -3736,6 +3789,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -3736,6 +3789,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
describe
'#codequality_reports'
do
describe
'#codequality_reports'
do
subject
(
:codequality_reports
)
{
pipeline
.
codequality_reports
}
subject
(
:codequality_reports
)
{
pipeline
.
codequality_reports
}
let_it_be
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
context
'when pipeline has multiple builds with codequality reports'
do
context
'when pipeline has multiple builds with codequality reports'
do
let
(
:build_rspec
)
{
create
(
:ci_build
,
:success
,
name:
'rspec'
,
pipeline:
pipeline
,
project:
project
)
}
let
(
:build_rspec
)
{
create
(
:ci_build
,
:success
,
name:
'rspec'
,
pipeline:
pipeline
,
project:
project
)
}
let
(
:build_golang
)
{
create
(
:ci_build
,
:success
,
name:
'golang'
,
pipeline:
pipeline
,
project:
project
)
}
let
(
:build_golang
)
{
create
(
:ci_build
,
:success
,
name:
'golang'
,
pipeline:
pipeline
,
project:
project
)
}
...
@@ -3767,6 +3822,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -3767,6 +3822,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'#total_size'
do
describe
'#total_size'
do
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let!
(
:build_job1
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
stage_idx:
0
)
}
let!
(
:build_job1
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
stage_idx:
0
)
}
let!
(
:build_job2
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
stage_idx:
0
)
}
let!
(
:build_job2
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
stage_idx:
0
)
}
let!
(
:test_job_failed_and_retried
)
{
create
(
:ci_build
,
:failed
,
:retried
,
pipeline:
pipeline
,
stage_idx:
1
)
}
let!
(
:test_job_failed_and_retried
)
{
create
(
:ci_build
,
:failed
,
:retried
,
pipeline:
pipeline
,
stage_idx:
1
)
}
...
@@ -3827,7 +3883,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -3827,7 +3883,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'#find_stage_by_name'
do
describe
'#find_stage_by_name'
do
let
(
:pipeline
)
{
create
(
:ci_pipeline
)
}
let
_it_be
(
:pipeline
)
{
create
(
:ci_pipeline
)
}
let
(
:stage_name
)
{
'test'
}
let
(
:stage_name
)
{
'test'
}
let
(
:stage
)
do
let
(
:stage
)
do
...
@@ -3908,6 +3964,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -3908,6 +3964,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
describe
'#parent_pipeline'
do
describe
'#parent_pipeline'
do
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be_with_reload
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
context
'when pipeline is triggered by a pipeline from the same project'
do
context
'when pipeline is triggered by a pipeline from the same project'
do
let_it_be
(
:upstream_pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let_it_be
(
:upstream_pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
...
@@ -3950,7 +4007,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -3950,7 +4007,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
describe
'#child_pipelines'
do
describe
'#child_pipelines'
do
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:project
)
{
create
(
:project
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let
_it_be_with_reload
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
context
'when pipeline triggered other pipelines on same project'
do
context
'when pipeline triggered other pipelines on same project'
do
let
(
:downstream_pipeline
)
{
create
(
:ci_pipeline
,
project:
pipeline
.
project
)
}
let
(
:downstream_pipeline
)
{
create
(
:ci_pipeline
,
project:
pipeline
.
project
)
}
...
@@ -4004,6 +4061,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -4004,6 +4061,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'upstream status interactions'
do
describe
'upstream status interactions'
do
let_it_be_with_reload
(
:pipeline
)
{
create
(
:ci_pipeline
,
status: :created
,
project:
project
)
}
context
'when a pipeline has an upstream status'
do
context
'when a pipeline has an upstream status'
do
context
'when an upstream status is a bridge'
do
context
'when an upstream status is a bridge'
do
let
(
:bridge
)
{
create
(
:ci_bridge
,
status: :pending
)
}
let
(
:bridge
)
{
create
(
:ci_bridge
,
status: :pending
)
}
...
@@ -4062,6 +4121,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -4062,6 +4121,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
describe
'#source_ref_path'
do
describe
'#source_ref_path'
do
subject
{
pipeline
.
source_ref_path
}
subject
{
pipeline
.
source_ref_path
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
status: :created
,
project:
project
)
}
context
'when pipeline is for a branch'
do
context
'when pipeline is for a branch'
do
it
{
is_expected
.
to
eq
(
Gitlab
::
Git
::
BRANCH_REF_PREFIX
+
pipeline
.
source_ref
.
to_s
)
}
it
{
is_expected
.
to
eq
(
Gitlab
::
Git
::
BRANCH_REF_PREFIX
+
pipeline
.
source_ref
.
to_s
)
}
end
end
...
@@ -4080,7 +4141,9 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -4080,7 +4141,9 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
end
end
describe
"#builds_with_coverage"
do
describe
'#builds_with_coverage'
do
let_it_be
(
:pipeline
)
{
create
(
:ci_pipeline
,
status: :created
,
project:
project
)
}
it
'returns builds with coverage only'
do
it
'returns builds with coverage only'
do
rspec
=
create
(
:ci_build
,
name:
'rspec'
,
coverage:
97.1
,
pipeline:
pipeline
)
rspec
=
create
(
:ci_build
,
name:
'rspec'
,
coverage:
97.1
,
pipeline:
pipeline
)
jest
=
create
(
:ci_build
,
name:
'jest'
,
coverage:
94.1
,
pipeline:
pipeline
)
jest
=
create
(
:ci_build
,
name:
'jest'
,
coverage:
94.1
,
pipeline:
pipeline
)
...
@@ -4104,10 +4167,11 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -4104,10 +4167,11 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'#base_and_ancestors'
do
describe
'#base_and_ancestors'
do
let
(
:same_project
)
{
false
}
subject
{
pipeline
.
base_and_ancestors
(
same_project:
same_project
)
}
subject
{
pipeline
.
base_and_ancestors
(
same_project:
same_project
)
}
let_it_be
(
:pipeline
)
{
create
(
:ci_pipeline
,
status: :created
,
project:
project
)
}
let
(
:same_project
)
{
false
}
context
'when pipeline is not child nor parent'
do
context
'when pipeline is not child nor parent'
do
it
'returns just the pipeline itself'
do
it
'returns just the pipeline itself'
do
expect
(
subject
).
to
contain_exactly
(
pipeline
)
expect
(
subject
).
to
contain_exactly
(
pipeline
)
...
@@ -4141,6 +4205,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -4141,6 +4205,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
context
'when pipeline is a child of a child pipeline'
do
context
'when pipeline is a child of a child pipeline'
do
let_it_be
(
:pipeline
)
{
create
(
:ci_pipeline
,
status: :created
,
project:
project
)
}
let
(
:ancestor
)
{
create
(
:ci_pipeline
,
project:
pipeline
.
project
)
}
let
(
:ancestor
)
{
create
(
:ci_pipeline
,
project:
pipeline
.
project
)
}
let
(
:parent
)
{
create
(
:ci_pipeline
,
project:
pipeline
.
project
)
}
let
(
:parent
)
{
create
(
:ci_pipeline
,
project:
pipeline
.
project
)
}
...
@@ -4155,6 +4220,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -4155,6 +4220,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
context
'when pipeline is a triggered pipeline'
do
context
'when pipeline is a triggered pipeline'
do
let_it_be
(
:pipeline
)
{
create
(
:ci_pipeline
,
status: :created
,
project:
project
)
}
let
(
:upstream
)
{
create
(
:ci_pipeline
,
project:
create
(
:project
))
}
let
(
:upstream
)
{
create
(
:ci_pipeline
,
project:
create
(
:project
))
}
before
do
before
do
...
@@ -4178,6 +4244,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -4178,6 +4244,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'reset_ancestor_bridges!'
do
describe
'reset_ancestor_bridges!'
do
let_it_be
(
:pipeline
)
{
create
(
:ci_pipeline
,
status: :created
,
project:
project
)
}
context
'when the pipeline is a child pipeline and the bridge is depended'
do
context
'when the pipeline is a child pipeline and the bridge is depended'
do
let!
(
:parent_pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let!
(
:parent_pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let!
(
:bridge
)
{
create_bridge
(
parent_pipeline
,
pipeline
,
true
)
}
let!
(
:bridge
)
{
create_bridge
(
parent_pipeline
,
pipeline
,
true
)
}
...
@@ -4239,6 +4307,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -4239,6 +4307,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'test failure history processing'
do
describe
'test failure history processing'
do
let
(
:pipeline
)
{
build
(
:ci_pipeline
,
status: :created
,
project:
project
)
}
it
'performs the service asynchronously when the pipeline is completed'
do
it
'performs the service asynchronously when the pipeline is completed'
do
service
=
double
service
=
double
...
@@ -4250,6 +4320,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -4250,6 +4320,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'#latest_test_report_builds'
do
describe
'#latest_test_report_builds'
do
let_it_be
(
:pipeline
)
{
create
(
:ci_pipeline
,
status: :created
,
project:
project
)
}
it
'returns pipeline builds with test report artifacts'
do
it
'returns pipeline builds with test report artifacts'
do
test_build
=
create
(
:ci_build
,
:test_reports
,
pipeline:
pipeline
,
project:
project
)
test_build
=
create
(
:ci_build
,
:test_reports
,
pipeline:
pipeline
,
project:
project
)
create
(
:ci_build
,
:artifacts
,
pipeline:
pipeline
,
project:
project
)
create
(
:ci_build
,
:artifacts
,
pipeline:
pipeline
,
project:
project
)
...
@@ -4274,6 +4346,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -4274,6 +4346,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'#builds_with_failed_tests'
do
describe
'#builds_with_failed_tests'
do
let_it_be
(
:pipeline
)
{
create
(
:ci_pipeline
,
status: :created
,
project:
project
)
}
it
'returns pipeline builds with test report artifacts'
do
it
'returns pipeline builds with test report artifacts'
do
failed_build
=
create
(
:ci_build
,
:failed
,
:test_reports
,
pipeline:
pipeline
,
project:
project
)
failed_build
=
create
(
:ci_build
,
:failed
,
:test_reports
,
pipeline:
pipeline
,
project:
project
)
create
(
:ci_build
,
:success
,
:test_reports
,
pipeline:
pipeline
,
project:
project
)
create
(
:ci_build
,
:success
,
:test_reports
,
pipeline:
pipeline
,
project:
project
)
...
...
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