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
Tatuya Kamada
gitlab-ce
Commits
db09d105
Commit
db09d105
authored
Feb 10, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for build retry service
parent
9202b1f4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
0 deletions
+62
-0
app/services/ci/retry_build_service.rb
app/services/ci/retry_build_service.rb
+6
-0
spec/services/ci/retry_build_service_spec.rb
spec/services/ci/retry_build_service_spec.rb
+56
-0
No files found.
app/services/ci/retry_build_service.rb
View file @
db09d105
module
Ci
module
Ci
class
RetryBuildService
class
RetryBuildService
include
Gitlab
::
Allowable
def
initialize
(
build
,
user
)
def
initialize
(
build
,
user
)
@build
=
build
@build
=
build
@user
=
user
@user
=
user
...
@@ -7,6 +9,10 @@ module Ci
...
@@ -7,6 +9,10 @@ module Ci
end
end
def
retry!
def
retry!
unless
can?
(
@user
,
:update_build
,
@build
)
raise
Gitlab
::
Access
::
AccessDeniedError
end
clone_build
.
tap
do
|
new_build
|
clone_build
.
tap
do
|
new_build
|
new_build
.
enqueue!
new_build
.
enqueue!
...
...
spec/services/ci/retry_build_service_spec.rb
0 → 100644
View file @
db09d105
require
'spec_helper'
describe
Ci
::
RetryBuildService
,
:services
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
let
(
:service
)
do
described_class
.
new
(
build
,
user
)
end
describe
'#retry!'
do
let
(
:new_build
)
{
service
.
retry!
}
context
'when user has ability to retry build'
do
before
do
project
.
team
<<
[
user
,
:developer
]
end
it
'creates a new build that represents the old one'
do
expect
(
new_build
.
name
).
to
eq
build
.
name
end
it
'enqueues the new build'
do
expect
(
new_build
).
to
be_pending
end
it
'resolves todos for old build that failed'
do
expect
(
MergeRequests
::
AddTodoWhenBuildFailsService
)
.
to
receive_message_chain
(
:new
,
:close
)
service
.
retry!
end
context
'when there are subsequent builds that are skipped'
do
let!
(
:subsequent_build
)
do
create
(
:ci_build
,
:skipped
,
stage_idx:
1
,
pipeline:
pipeline
)
end
it
'resumes pipeline processing in subsequent stages'
do
service
.
retry!
expect
(
subsequent_build
.
reload
).
to
be_created
end
end
end
context
'when user does not have ability to retry build'
do
it
'raises an error'
do
expect
{
service
.
retry!
}
.
to
raise_error
Gitlab
::
Access
::
AccessDeniedError
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