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
d7be9c37
Commit
d7be9c37
authored
May 13, 2021
by
Matija Čupić
Committed by
Douglas Barbosa Alexandre
May 17, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve background retry tests
parent
03ed05b0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
9 deletions
+28
-9
spec/controllers/projects/pipelines_controller_spec.rb
spec/controllers/projects/pipelines_controller_spec.rb
+26
-7
spec/workers/ci/retry_pipeline_worker_spec.rb
spec/workers/ci/retry_pipeline_worker_spec.rb
+2
-2
No files found.
spec/controllers/projects/pipelines_controller_spec.rb
View file @
d7be9c37
...
@@ -853,6 +853,15 @@ RSpec.describe Projects::PipelinesController do
...
@@ -853,6 +853,15 @@ RSpec.describe Projects::PipelinesController do
end
end
describe
'POST retry.json'
do
describe
'POST retry.json'
do
subject
(
:post_retry
)
do
post
:retry
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
pipeline
.
id
},
format: :json
end
let!
(
:pipeline
)
{
create
(
:ci_pipeline
,
:failed
,
project:
project
)
}
let!
(
:pipeline
)
{
create
(
:ci_pipeline
,
:failed
,
project:
project
)
}
let!
(
:build
)
{
create
(
:ci_build
,
:failed
,
pipeline:
pipeline
)
}
let!
(
:build
)
{
create
(
:ci_build
,
:failed
,
pipeline:
pipeline
)
}
...
@@ -860,24 +869,34 @@ RSpec.describe Projects::PipelinesController do
...
@@ -860,24 +869,34 @@ RSpec.describe Projects::PipelinesController do
before
do
before
do
stub_const
(
'::Ci::RetryPipelineWorker'
,
worker_spy
)
stub_const
(
'::Ci::RetryPipelineWorker'
,
worker_spy
)
post
:retry
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
pipeline
.
id
},
format: :json
end
end
it
'retries a pipeline in the background without returning any content'
do
it
'retries a pipeline in the background without returning any content'
do
post_retry
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
expect
(
::
Ci
::
RetryPipelineWorker
).
to
have_received
(
:perform_async
).
with
(
pipeline
.
id
,
user
.
id
)
expect
(
::
Ci
::
RetryPipelineWorker
).
to
have_received
(
:perform_async
).
with
(
pipeline
.
id
,
user
.
id
)
end
end
context
'when feature flag is disabled'
do
before
do
stub_feature_flags
(
background_pipeline_retry_endpoint:
false
)
end
it
'retries the pipeline without returning any content'
do
post_retry
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
expect
(
build
.
reload
).
to
be_retried
end
end
context
'when builds are disabled'
do
context
'when builds are disabled'
do
let
(
:feature
)
{
ProjectFeature
::
DISABLED
}
let
(
:feature
)
{
ProjectFeature
::
DISABLED
}
it
'fails to retry pipeline'
do
it
'fails to retry pipeline'
do
post_retry
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
...
...
spec/workers/ci/retry_pipeline_worker_spec.rb
View file @
d7be9c37
...
@@ -43,8 +43,8 @@ RSpec.describe Ci::RetryPipelineWorker do
...
@@ -43,8 +43,8 @@ RSpec.describe Ci::RetryPipelineWorker do
let
(
:pipeline_id
)
{
1234
}
let
(
:pipeline_id
)
{
1234
}
let
(
:user_id
)
{
1234
}
let
(
:user_id
)
{
1234
}
it
'returns
false
'
do
it
'returns
nil
'
do
expect
(
perform
).
to
eq
(
nil
)
expect
(
perform
).
to
be_nil
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