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
Léo-Paul Géneau
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
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
21 deletions
+8
-21
app/finders/pipelines_finder.rb
app/finders/pipelines_finder.rb
+3
-16
lib/api/pipelines.rb
lib/api/pipelines.rb
+1
-1
spec/finders/pipelines_finder_spec.rb
spec/finders/pipelines_finder_spec.rb
+2
-2
spec/requests/api/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
...
@@ -54,22 +54,9 @@ class PipelinesFinder
end
end
def
by_status
(
items
)
def
by_status
(
items
)
case
params
[
:status
]
return
items
unless
HasStatus
::
AVAILABLE_STATUSES
.
include?
(
params
[
:status
])
when
'running'
items
.
running
items
.
where
(
status:
params
[
:status
])
when
'pending'
items
.
pending
when
'success'
items
.
success
when
'failed'
items
.
failed
when
'canceled'
items
.
canceled
when
'skipped'
items
.
skipped
else
items
end
end
end
def
by_ref
(
items
)
def
by_ref
(
items
)
...
...
lib/api/pipelines.rb
View file @
0a36bfa9
...
@@ -16,7 +16,7 @@ module API
...
@@ -16,7 +16,7 @@ module API
use
:pagination
use
:pagination
optional
:scope
,
type:
String
,
values:
%w[running pending finished branches tags]
,
optional
:scope
,
type:
String
,
values:
%w[running pending finished branches tags]
,
desc:
'The scope of pipelines'
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'
desc:
'The status of pipelines'
optional
:ref
,
type:
String
,
desc:
'The ref of pipelines'
optional
:ref
,
type:
String
,
desc:
'The ref of pipelines'
optional
:yaml_errors
,
type:
Boolean
,
desc:
'If true, returns only yaml error 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
...
@@ -60,13 +60,13 @@ describe PipelinesFinder do
end
end
end
end
%w[running pending success failed canceled skipped]
.
each
do
|
target
|
HasStatus
::
AVAILABLE_STATUSES
.
each
do
|
target
|
context
"when status is
#{
target
}
"
do
context
"when status is
#{
target
}
"
do
let
(
:params
)
{
{
status:
target
}
}
let
(
:params
)
{
{
status:
target
}
}
let!
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
,
status:
target
)
}
let!
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
,
status:
target
)
}
before
do
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
)
create
(
:ci_pipeline
,
project:
project
,
status:
exception_status
.
sample
)
end
end
...
...
spec/requests/api/pipelines_spec.rb
View file @
0a36bfa9
...
@@ -95,11 +95,11 @@ describe API::Pipelines do
...
@@ -95,11 +95,11 @@ describe API::Pipelines do
end
end
end
end
%w[running pending success failed canceled skipped]
.
each
do
|
target
|
HasStatus
::
AVAILABLE_STATUSES
.
each
do
|
target
|
context
"when status is
#{
target
}
"
do
context
"when status is
#{
target
}
"
do
before
do
before
do
create
(
:ci_pipeline
,
project:
project
,
status:
target
)
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
)
create
(
:ci_pipeline
,
project:
project
,
status:
exception_status
.
sample
)
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