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
17580029
Commit
17580029
authored
Mar 08, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add name(User)
parent
83d02a0b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
8 deletions
+36
-8
app/finders/pipelines_finder.rb
app/finders/pipelines_finder.rb
+8
-0
doc/api/pipelines.md
doc/api/pipelines.md
+2
-1
lib/api/pipelines.rb
lib/api/pipelines.rb
+2
-1
spec/finders/pipelines_finder_spec.rb
spec/finders/pipelines_finder_spec.rb
+24
-6
No files found.
app/finders/pipelines_finder.rb
View file @
17580029
...
@@ -79,6 +79,14 @@ class PipelinesFinder
...
@@ -79,6 +79,14 @@ class PipelinesFinder
end
end
end
end
def
by_name
(
items
)
if
params
[
:name
].
present?
items
.
joins
(
:user
).
where
(
"users.name = ?"
,
params
[
:name
])
else
items
end
end
def
by_username
(
items
)
def
by_username
(
items
)
if
params
[
:username
].
present?
if
params
[
:username
].
present?
items
.
joins
(
:user
).
where
(
"users.username = ?"
,
params
[
:username
])
items
.
joins
(
:user
).
where
(
"users.username = ?"
,
params
[
:username
])
...
...
doc/api/pipelines.md
View file @
17580029
...
@@ -15,7 +15,8 @@ GET /projects/:id/pipelines
...
@@ -15,7 +15,8 @@ GET /projects/:id/pipelines
|
`status`
| string | no | The status of pipelines, one of:
`running`
,
`pending`
,
`success`
,
`failed`
,
`canceled`
,
`skipped`
; |
|
`status`
| string | no | The status of pipelines, one of:
`running`
,
`pending`
,
`success`
,
`failed`
,
`canceled`
,
`skipped`
; |
|
`ref`
| string | no | The ref of pipelines |
|
`ref`
| string | no | The ref of pipelines |
|
`yaml_errors`
| string | no | If true, returns only yaml error pipelines |
|
`yaml_errors`
| string | no | If true, returns only yaml error pipelines |
|
`username`
| string | no | The name of user who triggered pipelines |
|
`name`
| string | no | The name of user who triggered pipelines |
|
`username`
| string | no | The username of user who triggered pipelines |
|
`order_by`
| string | no | Return requests ordered by
`id`
,
`status`
,
`ref`
,
`username`
,
`started_at`
,
`finished_at`
,
`created_at`
or
`updated_at`
fields. Default is
`id`
|
|
`order_by`
| string | no | Return requests ordered by
`id`
,
`status`
,
`ref`
,
`username`
,
`started_at`
,
`finished_at`
,
`created_at`
or
`updated_at`
fields. Default is
`id`
|
|
`sort`
| string | no | Return requests sorted in
`asc`
or
`desc`
order. Default is
`desc`
|
|
`sort`
| string | no | Return requests sorted in
`asc`
or
`desc`
order. Default is
`desc`
|
...
...
lib/api/pipelines.rb
View file @
17580029
...
@@ -20,7 +20,8 @@ module API
...
@@ -20,7 +20,8 @@ module API
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'
optional
:username
,
type:
String
,
desc:
'The name of user who triggered pipelines'
optional
:name
,
type:
String
,
desc:
'The name of user who triggered pipelines'
optional
:username
,
type:
String
,
desc:
'The username of user who triggered pipelines'
optional
:order_by
,
type:
String
,
values:
%w[id status ref username started_at finished_at created_at updated_at]
,
default:
'id'
,
optional
:order_by
,
type:
String
,
values:
%w[id status ref username started_at finished_at created_at updated_at]
,
default:
'id'
,
desc:
'The order_by which is combined with a sort'
desc:
'The order_by which is combined with a sort'
optional
:sort
,
type:
String
,
values:
%w[asc desc]
,
default:
'desc'
,
optional
:sort
,
type:
String
,
values:
%w[asc desc]
,
default:
'desc'
,
...
...
spec/finders/pipelines_finder_spec.rb
View file @
17580029
...
@@ -134,7 +134,25 @@ describe PipelinesFinder do
...
@@ -134,7 +134,25 @@ describe PipelinesFinder do
end
end
context
'when a ref does not exist'
do
context
'when a ref does not exist'
do
let
(
:params
)
{
{
ref:
'unique-ref'
}
}
let
(
:params
)
{
{
ref:
'invalid-ref'
}
}
it
'selects nothing'
do
expect
(
subject
).
to
be_empty
end
end
end
context
'when a name is passed'
do
context
'when a name exists'
do
let
(
:params
)
{
{
name:
user1
.
name
}
}
it
'selects all pipelines which belong to the name'
do
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
where
(
user:
user1
))
end
end
context
'when a name does not exist'
do
let
(
:params
)
{
{
name:
'invalid-name'
}
}
it
'selects nothing'
do
it
'selects nothing'
do
expect
(
subject
).
to
be_empty
expect
(
subject
).
to
be_empty
...
@@ -152,7 +170,7 @@ describe PipelinesFinder do
...
@@ -152,7 +170,7 @@ describe PipelinesFinder do
end
end
context
'when a username does not exist'
do
context
'when a username does not exist'
do
let
(
:params
)
{
{
username:
'
unique
-username'
}
}
let
(
:params
)
{
{
username:
'
invalid
-username'
}
}
it
'selects nothing'
do
it
'selects nothing'
do
expect
(
subject
).
to
be_empty
expect
(
subject
).
to
be_empty
...
@@ -204,7 +222,7 @@ describe PipelinesFinder do
...
@@ -204,7 +222,7 @@ describe PipelinesFinder do
end
end
context
'when order_by does not exist'
do
context
'when order_by does not exist'
do
let
(
:params
)
{
{
order_by:
'
abnormal
_column'
,
sort:
'desc'
}
}
let
(
:params
)
{
{
order_by:
'
invalid
_column'
,
sort:
'desc'
}
}
it
'sorts by default'
do
it
'sorts by default'
do
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
order
(
id: :desc
))
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
order
(
id: :desc
))
...
@@ -212,7 +230,7 @@ describe PipelinesFinder do
...
@@ -212,7 +230,7 @@ describe PipelinesFinder do
end
end
context
'when sort does not exist'
do
context
'when sort does not exist'
do
let
(
:params
)
{
{
order_by:
'created_at'
,
sort:
'
abnormal
_sort'
}
}
let
(
:params
)
{
{
order_by:
'created_at'
,
sort:
'
invalid
_sort'
}
}
it
'sorts by default'
do
it
'sorts by default'
do
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
order
(
id: :desc
))
expect
(
subject
).
to
match_array
(
Ci
::
Pipeline
.
order
(
id: :desc
))
...
...
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