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
227cbdd8
Commit
227cbdd8
authored
Jan 12, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use detailed status for failed but allowed builds
parent
6053049f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
118 additions
and
14 deletions
+118
-14
lib/gitlab/ci/status/build/factory.rb
lib/gitlab/ci/status/build/factory.rb
+5
-2
spec/lib/gitlab/ci/status/build/factory_spec.rb
spec/lib/gitlab/ci/status/build/factory_spec.rb
+113
-12
No files found.
lib/gitlab/ci/status/build/factory.rb
View file @
227cbdd8
...
@@ -4,8 +4,11 @@ module Gitlab
...
@@ -4,8 +4,11 @@ module Gitlab
module
Build
module
Build
class
Factory
<
Status
::
Factory
class
Factory
<
Status
::
Factory
def
self
.
extended_statuses
def
self
.
extended_statuses
[
Status
::
Build
::
Stop
,
Status
::
Build
::
Play
,
[[
Status
::
Build
::
Cancelable
,
Status
::
Build
::
Cancelable
,
Status
::
Build
::
Retryable
]
Status
::
Build
::
Retryable
],
[
Status
::
Build
::
FailedAllowed
,
Status
::
Build
::
Play
,
Status
::
Build
::
Stop
]]
end
end
def
self
.
common_helpers
def
self
.
common_helpers
...
...
spec/lib/gitlab/ci/status/build/factory_spec.rb
View file @
227cbdd8
...
@@ -3,15 +3,23 @@ require 'spec_helper'
...
@@ -3,15 +3,23 @@ require 'spec_helper'
describe
Gitlab
::
Ci
::
Status
::
Build
::
Factory
do
describe
Gitlab
::
Ci
::
Status
::
Build
::
Factory
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
build
.
project
}
let
(
:project
)
{
build
.
project
}
let
(
:status
)
{
factory
.
fabricate!
}
subject
{
described_class
.
new
(
build
,
user
)
}
let
(
:factory
)
{
described_class
.
new
(
build
,
user
)
}
let
(
:status
)
{
subject
.
fabricate!
}
before
{
project
.
team
<<
[
user
,
:developer
]
}
before
{
project
.
team
<<
[
user
,
:developer
]
}
context
'when build is successful'
do
context
'when build is successful'
do
let
(
:build
)
{
create
(
:ci_build
,
:success
)
}
let
(
:build
)
{
create
(
:ci_build
,
:success
)
}
it
'matches correct core status'
do
expect
(
factory
.
core_status
).
to
be_a
Gitlab
::
Ci
::
Status
::
Success
end
it
'matches correct extended statuses'
do
expect
(
factory
.
extended_statuses
)
.
to
eq
[
Gitlab
::
Ci
::
Status
::
Build
::
Retryable
]
end
it
'fabricates a retryable build status'
do
it
'fabricates a retryable build status'
do
expect
(
status
).
to
be_a
Gitlab
::
Ci
::
Status
::
Build
::
Retryable
expect
(
status
).
to
be_a
Gitlab
::
Ci
::
Status
::
Build
::
Retryable
end
end
...
@@ -26,24 +34,72 @@ describe Gitlab::Ci::Status::Build::Factory do
...
@@ -26,24 +34,72 @@ describe Gitlab::Ci::Status::Build::Factory do
end
end
context
'when build is failed'
do
context
'when build is failed'
do
let
(
:build
)
{
create
(
:ci_build
,
:failed
)
}
context
'when build is not allowed to fail'
do
let
(
:build
)
{
create
(
:ci_build
,
:failed
)
}
it
'fabricates a retryable build status'
do
it
'matches correct core status'
do
expect
(
status
).
to
be_a
Gitlab
::
Ci
::
Status
::
Build
::
Retryable
expect
(
factory
.
core_status
).
to
be_a
Gitlab
::
Ci
::
Status
::
Failed
end
it
'matches correct extended statuses'
do
expect
(
factory
.
extended_statuses
)
.
to
eq
[
Gitlab
::
Ci
::
Status
::
Build
::
Retryable
]
end
it
'fabricates a retryable build status'
do
expect
(
status
).
to
be_a
Gitlab
::
Ci
::
Status
::
Build
::
Retryable
end
it
'fabricates status with correct details'
do
expect
(
status
.
text
).
to
eq
'failed'
expect
(
status
.
icon
).
to
eq
'icon_status_failed'
expect
(
status
.
label
).
to
eq
'failed'
expect
(
status
).
to
have_details
expect
(
status
).
to
have_action
end
end
end
it
'fabricates status with correct details'
do
context
'when build is allowed to fail'
do
expect
(
status
.
text
).
to
eq
'failed'
let
(
:build
)
{
create
(
:ci_build
,
:failed
,
:allowed_to_fail
)
}
expect
(
status
.
icon
).
to
eq
'icon_status_failed'
expect
(
status
.
label
).
to
eq
'failed'
it
'matches correct core status'
do
expect
(
status
).
to
have_details
expect
(
factory
.
core_status
).
to
be_a
Gitlab
::
Ci
::
Status
::
Failed
expect
(
status
).
to
have_action
end
it
'matches correct extended statuses'
do
expect
(
factory
.
extended_statuses
)
.
to
eq
[
Gitlab
::
Ci
::
Status
::
Build
::
Retryable
,
Gitlab
::
Ci
::
Status
::
Build
::
FailedAllowed
]
end
it
'fabricates a failed but allowed build status'
do
expect
(
status
).
to
be_a
Gitlab
::
Ci
::
Status
::
Build
::
FailedAllowed
end
it
'fabricates status with correct details'
do
expect
(
status
.
text
).
to
eq
'failed'
expect
(
status
.
icon
).
to
eq
'icon_status_warning'
expect
(
status
.
label
).
to
eq
'failed (allowed to fail)'
expect
(
status
).
to
have_details
expect
(
status
).
to
have_action
expect
(
status
.
action_title
).
to
include
'Retry'
expect
(
status
.
action_path
).
to
include
'retry'
end
end
end
end
end
context
'when build is a canceled'
do
context
'when build is a canceled'
do
let
(
:build
)
{
create
(
:ci_build
,
:canceled
)
}
let
(
:build
)
{
create
(
:ci_build
,
:canceled
)
}
it
'matches correct core status'
do
expect
(
factory
.
core_status
).
to
be_a
Gitlab
::
Ci
::
Status
::
Canceled
end
it
'matches correct extended statuses'
do
expect
(
factory
.
extended_statuses
)
.
to
eq
[
Gitlab
::
Ci
::
Status
::
Build
::
Retryable
]
end
it
'fabricates a retryable build status'
do
it
'fabricates a retryable build status'
do
expect
(
status
).
to
be_a
Gitlab
::
Ci
::
Status
::
Build
::
Retryable
expect
(
status
).
to
be_a
Gitlab
::
Ci
::
Status
::
Build
::
Retryable
end
end
...
@@ -60,6 +116,15 @@ describe Gitlab::Ci::Status::Build::Factory do
...
@@ -60,6 +116,15 @@ describe Gitlab::Ci::Status::Build::Factory do
context
'when build is running'
do
context
'when build is running'
do
let
(
:build
)
{
create
(
:ci_build
,
:running
)
}
let
(
:build
)
{
create
(
:ci_build
,
:running
)
}
it
'matches correct core status'
do
expect
(
factory
.
core_status
).
to
be_a
Gitlab
::
Ci
::
Status
::
Running
end
it
'matches correct extended statuses'
do
expect
(
factory
.
extended_statuses
)
.
to
eq
[
Gitlab
::
Ci
::
Status
::
Build
::
Cancelable
]
end
it
'fabricates a canceable build status'
do
it
'fabricates a canceable build status'
do
expect
(
status
).
to
be_a
Gitlab
::
Ci
::
Status
::
Build
::
Cancelable
expect
(
status
).
to
be_a
Gitlab
::
Ci
::
Status
::
Build
::
Cancelable
end
end
...
@@ -76,6 +141,15 @@ describe Gitlab::Ci::Status::Build::Factory do
...
@@ -76,6 +141,15 @@ describe Gitlab::Ci::Status::Build::Factory do
context
'when build is pending'
do
context
'when build is pending'
do
let
(
:build
)
{
create
(
:ci_build
,
:pending
)
}
let
(
:build
)
{
create
(
:ci_build
,
:pending
)
}
it
'matches correct core status'
do
expect
(
factory
.
core_status
).
to
be_a
Gitlab
::
Ci
::
Status
::
Pending
end
it
'matches correct extended statuses'
do
expect
(
factory
.
extended_statuses
)
.
to
eq
[
Gitlab
::
Ci
::
Status
::
Build
::
Cancelable
]
end
it
'fabricates a cancelable build status'
do
it
'fabricates a cancelable build status'
do
expect
(
status
).
to
be_a
Gitlab
::
Ci
::
Status
::
Build
::
Cancelable
expect
(
status
).
to
be_a
Gitlab
::
Ci
::
Status
::
Build
::
Cancelable
end
end
...
@@ -92,6 +166,14 @@ describe Gitlab::Ci::Status::Build::Factory do
...
@@ -92,6 +166,14 @@ describe Gitlab::Ci::Status::Build::Factory do
context
'when build is skipped'
do
context
'when build is skipped'
do
let
(
:build
)
{
create
(
:ci_build
,
:skipped
)
}
let
(
:build
)
{
create
(
:ci_build
,
:skipped
)
}
it
'matches correct core status'
do
expect
(
factory
.
core_status
).
to
be_a
Gitlab
::
Ci
::
Status
::
Skipped
end
it
'does not match extended statuses'
do
expect
(
factory
.
extended_statuses
).
to
be_empty
end
it
'fabricates a core skipped status'
do
it
'fabricates a core skipped status'
do
expect
(
status
).
to
be_a
Gitlab
::
Ci
::
Status
::
Skipped
expect
(
status
).
to
be_a
Gitlab
::
Ci
::
Status
::
Skipped
end
end
...
@@ -109,6 +191,15 @@ describe Gitlab::Ci::Status::Build::Factory do
...
@@ -109,6 +191,15 @@ describe Gitlab::Ci::Status::Build::Factory do
context
'when build is a play action'
do
context
'when build is a play action'
do
let
(
:build
)
{
create
(
:ci_build
,
:playable
)
}
let
(
:build
)
{
create
(
:ci_build
,
:playable
)
}
it
'matches correct core status'
do
expect
(
factory
.
core_status
).
to
be_a
Gitlab
::
Ci
::
Status
::
Skipped
end
it
'matches correct extended statuses'
do
expect
(
factory
.
extended_statuses
)
.
to
eq
[
Gitlab
::
Ci
::
Status
::
Build
::
Play
]
end
it
'fabricates a core skipped status'
do
it
'fabricates a core skipped status'
do
expect
(
status
).
to
be_a
Gitlab
::
Ci
::
Status
::
Build
::
Play
expect
(
status
).
to
be_a
Gitlab
::
Ci
::
Status
::
Build
::
Play
end
end
...
@@ -119,12 +210,22 @@ describe Gitlab::Ci::Status::Build::Factory do
...
@@ -119,12 +210,22 @@ describe Gitlab::Ci::Status::Build::Factory do
expect
(
status
.
label
).
to
eq
'manual play action'
expect
(
status
.
label
).
to
eq
'manual play action'
expect
(
status
).
to
have_details
expect
(
status
).
to
have_details
expect
(
status
).
to
have_action
expect
(
status
).
to
have_action
expect
(
status
.
action_path
).
to
include
'play'
end
end
end
end
context
'when build is an environment stop action'
do
context
'when build is an environment stop action'
do
let
(
:build
)
{
create
(
:ci_build
,
:playable
,
:teardown_environment
)
}
let
(
:build
)
{
create
(
:ci_build
,
:playable
,
:teardown_environment
)
}
it
'matches correct core status'
do
expect
(
factory
.
core_status
).
to
be_a
Gitlab
::
Ci
::
Status
::
Skipped
end
it
'matches correct extended statuses'
do
expect
(
factory
.
extended_statuses
)
.
to
eq
[
Gitlab
::
Ci
::
Status
::
Build
::
Stop
]
end
it
'fabricates a core skipped status'
do
it
'fabricates a core skipped status'
do
expect
(
status
).
to
be_a
Gitlab
::
Ci
::
Status
::
Build
::
Stop
expect
(
status
).
to
be_a
Gitlab
::
Ci
::
Status
::
Build
::
Stop
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