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
Jérome Perrin
gitlab-ce
Commits
d28f5e77
Commit
d28f5e77
authored
Dec 05, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement pipeline status factory with extended status
parent
b86d8afe
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
0 deletions
+76
-0
lib/gitlab/ci/status/pipeline/factory.rb
lib/gitlab/ci/status/pipeline/factory.rb
+39
-0
spec/lib/gitlab/ci/status/pipeline/factory_spec.rb
spec/lib/gitlab/ci/status/pipeline/factory_spec.rb
+37
-0
No files found.
lib/gitlab/ci/status/pipeline/factory.rb
0 → 100644
View file @
d28f5e77
module
Gitlab
module
Ci
module
Status
module
Pipeline
class
Factory
EXTENDED_STATUSES
=
[
Pipeline
::
SuccessWithWarnings
]
def
initialize
(
pipeline
)
@pipeline
=
pipeline
@status
=
pipeline
.
status
||
:created
end
def
fabricate!
if
extended_status
extended_status
.
new
(
core_status
)
else
core_status
end
end
private
def
core_status
Gitlab
::
Ci
::
Status
.
const_get
(
@status
.
capitalize
)
.
new
(
@pipeline
)
.
extend
(
Status
::
Pipeline
::
Common
)
end
def
extended_status
@extended
||=
EXTENDED_STATUSES
.
find
do
|
status
|
status
.
matches?
(
@pipeline
)
end
end
end
end
end
end
end
spec/lib/gitlab/ci/status/pipeline/factory_spec.rb
0 → 100644
View file @
d28f5e77
require
'spec_helper'
describe
Gitlab
::
Ci
::
Status
::
Pipeline
::
Factory
do
subject
do
described_class
.
new
(
pipeline
)
end
context
'when pipeline has a core status'
do
HasStatus
::
AVAILABLE_STATUSES
.
each
do
|
core_status
|
context
"when core status is
#{
core_status
}
"
do
let
(
:pipeline
)
do
create
(
:ci_pipeline
,
status:
core_status
)
end
it
"fabricates a core status
#{
core_status
}
"
do
expect
(
subject
.
fabricate!
)
.
to
be_a
Gitlab
::
Ci
::
Status
.
const_get
(
core_status
.
capitalize
)
end
end
end
end
context
'when pipeline has warnings'
do
let
(
:pipeline
)
do
create
(
:ci_pipeline
,
status: :success
)
end
before
do
create
(
:ci_build
,
:allowed_to_fail
,
:failed
,
pipeline:
pipeline
)
end
it
'fabricates extended "success with warnings" status'
do
expect
(
subject
.
fabricate!
)
.
to
be_a
Gitlab
::
Ci
::
Status
::
Pipeline
::
SuccessWithWarnings
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