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
Boxiang Sun
gitlab-ce
Commits
93c72e0f
Commit
93c72e0f
authored
Dec 07, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Ci::Status::Factory
parent
c4e46c57
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
76 additions
and
51 deletions
+76
-51
lib/gitlab/ci/status/factory.rb
lib/gitlab/ci/status/factory.rb
+43
-0
lib/gitlab/ci/status/pipeline/factory.rb
lib/gitlab/ci/status/pipeline/factory.rb
+5
-25
lib/gitlab/ci/status/stage/factory.rb
lib/gitlab/ci/status/stage/factory.rb
+2
-26
spec/lib/gitlab/ci/status/factory_spec.rb
spec/lib/gitlab/ci/status/factory_spec.rb
+26
-0
No files found.
lib/gitlab/ci/status/factory.rb
0 → 100644
View file @
93c72e0f
module
Gitlab
module
Ci
module
Status
class
Factory
attr_reader
:subject
def
initialize
(
subject
)
@subject
=
subject
end
def
fabricate!
if
extended_status
extended_status
.
new
(
core_status
)
else
core_status
end
end
private
def
subject_status
@subject_status
||=
subject
.
status
end
def
core_status
Gitlab
::
Ci
::
Status
.
const_get
(
subject_status
.
capitalize
)
.
new
(
subject
)
end
def
extended_status
@extended
||=
extended_statuses
.
find
do
|
status
|
status
.
matches?
(
subject
)
end
end
def
extended_statuses
[]
end
end
end
end
end
lib/gitlab/ci/status/pipeline/factory.rb
View file @
93c72e0f
...
...
@@ -2,35 +2,15 @@ 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
class
Factory
<
Status
::
Factory
private
def
core_status
Gitlab
::
Ci
::
Status
.
const_get
(
@status
.
capitalize
)
.
new
(
@pipeline
)
.
extend
(
Status
::
Pipeline
::
Common
)
def
extended_statuses
[
Pipeline
::
SuccessWithWarnings
]
end
def
extended_status
@extended
||=
EXTENDED_STATUSES
.
find
do
|
status
|
status
.
matches?
(
@pipeline
)
end
def
core_status
super
.
extend
(
Status
::
Pipeline
::
Common
)
end
end
end
...
...
lib/gitlab/ci/status/stage/factory.rb
View file @
93c72e0f
...
...
@@ -2,35 +2,11 @@ module Gitlab
module
Ci
module
Status
module
Stage
class
Factory
EXTENDED_STATUSES
=
[]
def
initialize
(
stage
)
@stage
=
stage
@status
=
stage
.
status
||
:created
end
def
fabricate!
if
extended_status
extended_status
.
new
(
core_status
)
else
core_status
end
end
class
Factory
<
Status
::
Factory
private
def
core_status
Gitlab
::
Ci
::
Status
.
const_get
(
@status
.
capitalize
)
.
new
(
@stage
)
.
extend
(
Status
::
Stage
::
Common
)
end
def
extended_status
@extended
||=
EXTENDED_STATUSES
.
find
do
|
status
|
status
.
matches?
(
@stage
)
end
super
.
extend
(
Status
::
Stage
::
Common
)
end
end
end
...
...
spec/lib/gitlab/ci/status/factory_spec.rb
0 → 100644
View file @
93c72e0f
require
'spec_helper'
describe
Gitlab
::
Ci
::
Status
::
Factory
do
let
(
:object
)
{
double
(
status: :created
)
}
subject
do
described_class
.
new
(
object
)
end
let
(
:status
)
do
subject
.
fabricate!
end
context
'when object has a core status'
do
HasStatus
::
AVAILABLE_STATUSES
.
each
do
|
core_status
|
context
"when core status is
#{
core_status
}
"
do
let
(
:object
)
{
double
(
status:
core_status
)
}
it
"fabricates a core status
#{
core_status
}
"
do
expect
(
status
).
to
be_a
(
Gitlab
::
Ci
::
Status
.
const_get
(
core_status
.
capitalize
))
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