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
03ff7179
Commit
03ff7179
authored
Oct 04, 2020
by
Peter Leitzen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Speed up CI retry build service specs
parent
3934a31b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
13 deletions
+17
-13
spec/services/ci/retry_build_service_spec.rb
spec/services/ci/retry_build_service_spec.rb
+17
-13
No files found.
spec/services/ci/retry_build_service_spec.rb
View file @
03ff7179
...
...
@@ -3,25 +3,32 @@
require
'spec_helper'
RSpec
.
describe
Ci
::
RetryBuildService
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:reporter
)
{
create
(
:user
)
}
let_it_be
(
:developer
)
{
create
(
:user
)
}
let_it_be
(
:project
)
{
create
(
:project
,
:repository
)
}
let_it_be
(
:pipeline
)
do
create
(
:ci_pipeline
,
project:
project
,
sha:
'b83d6e391c22777fca1ed3012fce84f633d7fed0'
)
end
let
(
:stage
)
do
let
_it_be
(
:stage
)
do
create
(
:ci_stage_entity
,
project:
project
,
pipeline:
pipeline
,
name:
'test'
)
end
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
stage_id:
stage
.
id
)
}
let_it_be_with_refind
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
stage_id:
stage
.
id
)
}
let
(
:user
)
{
developer
}
let
(
:service
)
do
described_class
.
new
(
project
,
user
)
end
before_all
do
project
.
add_developer
(
developer
)
project
.
add_reporter
(
reporter
)
end
clone_accessors
=
described_class
.
clone_accessors
reject_accessors
=
...
...
@@ -53,9 +60,9 @@ RSpec.describe Ci::RetryBuildService do
pipeline_id report_results pending_state pages_deployments]
.
freeze
shared_examples
'build duplication'
do
let
(
:another_pipeline
)
{
create
(
:ci_empty_pipeline
,
project:
project
)
}
let
_it_be
(
:another_pipeline
)
{
create
(
:ci_empty_pipeline
,
project:
project
)
}
let
(
:build
)
do
let
_it_be
(
:build
)
do
create
(
:ci_build
,
:failed
,
:expired
,
:erased
,
:queued
,
:coverage
,
:tags
,
:allowed_to_fail
,
:on_tag
,
:triggered
,
:teardown_environment
,
:resource_group
,
description:
'my-job'
,
stage:
'test'
,
stage_id:
stage
.
id
,
...
...
@@ -63,7 +70,7 @@ RSpec.describe Ci::RetryBuildService do
scheduled_at:
10
.
seconds
.
since
)
end
before
do
before
_all
do
# Test correctly behaviour of deprecated artifact because it can be still in use
stub_feature_flags
(
drop_license_management_artifact:
false
)
...
...
@@ -81,8 +88,6 @@ RSpec.describe Ci::RetryBuildService do
create
(
:ci_job_variable
,
job:
build
)
create
(
:ci_build_need
,
build:
build
)
build
.
reload
end
describe
'clone accessors'
do
...
...
@@ -162,8 +167,6 @@ RSpec.describe Ci::RetryBuildService do
context
'when user has ability to execute build'
do
before
do
stub_not_protect_default_branch
project
.
add_developer
(
user
)
end
it_behaves_like
'build duplication'
...
...
@@ -235,7 +238,6 @@ RSpec.describe Ci::RetryBuildService do
context
'when the pipeline is a child pipeline and the bridge is depended'
do
let!
(
:parent_pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let!
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let!
(
:bridge
)
{
create
(
:ci_bridge
,
:strategy_depend
,
pipeline:
parent_pipeline
,
status:
'success'
)
}
let!
(
:source_pipeline
)
{
create
(
:ci_sources_pipeline
,
pipeline:
pipeline
,
source_job:
bridge
)
}
...
...
@@ -248,6 +250,8 @@ RSpec.describe Ci::RetryBuildService do
end
context
'when user does not have ability to execute build'
do
let
(
:user
)
{
reporter
}
it
'raises an error'
do
expect
{
service
.
execute
(
build
)
}
.
to
raise_error
Gitlab
::
Access
::
AccessDeniedError
...
...
@@ -265,8 +269,6 @@ RSpec.describe Ci::RetryBuildService do
context
'when user has ability to execute build'
do
before
do
stub_not_protect_default_branch
project
.
add_developer
(
user
)
end
it_behaves_like
'build duplication'
...
...
@@ -316,6 +318,8 @@ RSpec.describe Ci::RetryBuildService do
end
context
'when user does not have ability to execute build'
do
let
(
:user
)
{
reporter
}
it
'raises an error'
do
expect
{
service
.
reprocess!
(
build
)
}
.
to
raise_error
Gitlab
::
Access
::
AccessDeniedError
...
...
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