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
c5e78808
Commit
c5e78808
authored
Feb 13, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix CI build specs after adding retry ability check
parent
db09d105
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
21 deletions
+33
-21
app/models/ci/build.rb
app/models/ci/build.rb
+3
-3
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+30
-18
No files found.
app/models/ci/build.rb
View file @
c5e78808
...
...
@@ -62,8 +62,8 @@ module Ci
new_build
.
save
end
def
retry
(
build
,
user
=
nil
)
Ci
::
RetryBuildService
.
new
(
build
,
user
).
retry!
def
retry
(
build
,
current_user
)
Ci
::
RetryBuildService
.
new
(
build
,
current_
user
).
retry!
end
end
...
...
@@ -111,7 +111,7 @@ module Ci
project
.
builds_enabled?
&&
commands
.
present?
&&
manual?
&&
skipped?
end
def
play
(
current_user
=
nil
)
def
play
(
current_user
)
# Try to queue a current build
if
self
.
enqueue
self
.
update
(
user:
current_user
)
...
...
spec/models/ci/build_spec.rb
View file @
c5e78808
require
'spec_helper'
describe
Ci
::
Build
,
:models
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
let
(
:test_trace
)
{
'This is a test'
}
...
...
@@ -207,14 +208,16 @@ describe Ci::Build, :models do
end
it
'expects to have retried builds instead the original ones'
do
retried_rspec
=
Ci
::
Build
.
retry
(
rspec_test
)
expect
(
staging
.
depends_on_builds
.
map
(
&
:id
)).
to
contain_exactly
(
build
.
id
,
retried_rspec
.
id
,
rubocop_test
.
id
)
project
.
team
<<
[
user
,
:developer
]
retried_rspec
=
Ci
::
Build
.
retry
(
rspec_test
,
user
)
expect
(
staging
.
depends_on_builds
.
map
(
&
:id
))
.
to
contain_exactly
(
build
.
id
,
retried_rspec
.
id
,
rubocop_test
.
id
)
end
end
describe
'#detailed_status'
do
let
(
:user
)
{
create
(
:user
)
}
it
'returns a detailed status'
do
expect
(
build
.
detailed_status
(
user
))
.
to
be_a
Gitlab
::
Ci
::
Status
::
Build
::
Cancelable
...
...
@@ -813,12 +816,16 @@ describe Ci::Build, :models do
subject
{
build
.
other_actions
}
before
do
project
.
team
<<
[
user
,
:developer
]
end
it
'returns other actions'
do
is_expected
.
to
contain_exactly
(
other_build
)
end
context
'when build is retried'
do
let!
(
:new_build
)
{
Ci
::
Build
.
retry
(
build
)
}
let!
(
:new_build
)
{
Ci
::
Build
.
retry
(
build
,
user
)
}
it
'does not return any of them'
do
is_expected
.
not_to
include
(
build
,
new_build
)
...
...
@@ -826,7 +833,7 @@ describe Ci::Build, :models do
end
context
'when other build is retried'
do
let!
(
:retried_build
)
{
Ci
::
Build
.
retry
(
other_build
)
}
let!
(
:retried_build
)
{
Ci
::
Build
.
retry
(
other_build
,
user
)
}
it
'returns a retried build'
do
is_expected
.
to
contain_exactly
(
retried_build
)
...
...
@@ -857,21 +864,29 @@ describe Ci::Build, :models do
describe
'#play'
do
let
(
:build
)
{
create
(
:ci_build
,
:manual
,
pipeline:
pipeline
)
}
subject
{
build
.
play
}
before
do
project
.
team
<<
[
user
,
:developer
]
end
context
'when build is manual'
do
it
'enqueues a build'
do
is_expected
.
to
be_pending
is_expected
.
to
eq
(
build
)
new_build
=
build
.
play
(
user
)
expect
(
new_build
).
to
be_pending
expect
(
new_build
).
to
eq
(
build
)
end
end
context
'
for successful buil
d'
do
context
'
when build is passe
d'
do
before
do
build
.
update
(
status:
'success'
)
end
it
'creates a new build'
do
is_expected
.
to
be_pending
is_expected
.
not_to
eq
(
build
)
new_build
=
build
.
play
(
user
)
expect
(
new_build
).
to
be_pending
expect
(
new_build
).
not_to
eq
(
build
)
end
end
end
...
...
@@ -1246,12 +1261,9 @@ describe Ci::Build, :models do
end
context
'when build has user'
do
let
(
:user
)
{
create
(
:user
,
username:
'starter'
)
}
let
(
:user_variables
)
do
[
{
key:
'GITLAB_USER_ID'
,
value:
user
.
id
.
to_s
,
public:
true
},
{
key:
'GITLAB_USER_EMAIL'
,
value:
user
.
email
,
public:
true
}
]
[
{
key:
'GITLAB_USER_ID'
,
value:
user
.
id
.
to_s
,
public:
true
},
{
key:
'GITLAB_USER_EMAIL'
,
value:
user
.
email
,
public:
true
}
]
end
before
do
...
...
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