BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
0a36bfa9
Commit
0a36bfa9
authored
Mar 30, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use HasStatus::AVAILABLE_STATUSES instead of hard coding
parent
4bd0d8e4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
21 deletions
+8
-21
pipelines_finder.rb
app/finders/pipelines_finder.rb
+3
-16
pipelines.rb
lib/api/pipelines.rb
+1
-1
pipelines_finder_spec.rb
spec/finders/pipelines_finder_spec.rb
+2
-2
pipelines_spec.rb
spec/requests/api/pipelines_spec.rb
+2
-2
No files found.
app/finders/pipelines_finder.rb
View file @
0a36bfa9
...
...
@@ -54,22 +54,9 @@ class PipelinesFinder
end
def
by_status
(
items
)
case
params
[
:status
]
when
'running'
items
.
running
when
'pending'
items
.
pending
when
'success'
items
.
success
when
'failed'
items
.
failed
when
'canceled'
items
.
canceled
when
'skipped'
items
.
skipped
else
items
end
return
items
unless
HasStatus
::
AVAILABLE_STATUSES
.
include?
(
params
[
:status
])
items
.
where
(
status:
params
[
:status
])
end
def
by_ref
(
items
)
...
...
lib/api/pipelines.rb
View file @
0a36bfa9
...
...
@@ -16,7 +16,7 @@ module API
use
:pagination
optional
:scope
,
type:
String
,
values:
%w[running pending finished branches tags]
,
desc:
'The scope of pipelines'
optional
:status
,
type:
String
,
values:
%w[running pending success failed canceled skipped]
,
optional
:status
,
type:
String
,
values:
HasStatus
::
AVAILABLE_STATUSES
,
desc:
'The status of pipelines'
optional
:ref
,
type:
String
,
desc:
'The ref of pipelines'
optional
:yaml_errors
,
type:
Boolean
,
desc:
'If true, returns only yaml error pipelines'
...
...
spec/finders/pipelines_finder_spec.rb
View file @
0a36bfa9
...
...
@@ -60,13 +60,13 @@ describe PipelinesFinder do
end
end
%w[running pending success failed canceled skipped]
.
each
do
|
target
|
HasStatus
::
AVAILABLE_STATUSES
.
each
do
|
target
|
context
"when status is
#{
target
}
"
do
let
(
:params
)
{
{
status:
target
}
}
let!
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
,
status:
target
)
}
before
do
exception_status
=
%w[running pending success failed canceled skipped]
-
[
target
]
exception_status
=
HasStatus
::
AVAILABLE_STATUSES
-
[
target
]
create
(
:ci_pipeline
,
project:
project
,
status:
exception_status
.
sample
)
end
...
...
spec/requests/api/pipelines_spec.rb
View file @
0a36bfa9
...
...
@@ -95,11 +95,11 @@ describe API::Pipelines do
end
end
%w[running pending success failed canceled skipped]
.
each
do
|
target
|
HasStatus
::
AVAILABLE_STATUSES
.
each
do
|
target
|
context
"when status is
#{
target
}
"
do
before
do
create
(
:ci_pipeline
,
project:
project
,
status:
target
)
exception_status
=
%w[running pending success failed canceled skipped]
-
[
target
]
exception_status
=
HasStatus
::
AVAILABLE_STATUSES
-
[
target
]
create
(
:ci_pipeline
,
project:
project
,
status:
exception_status
.
sample
)
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