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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
fd302061
Commit
fd302061
authored
Mar 01, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix rubocop offences and rspec failures
parent
df834306
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
28 deletions
+27
-28
app/finders/pipelines_finder.rb
app/finders/pipelines_finder.rb
+2
-2
lib/api/pipelines.rb
lib/api/pipelines.rb
+3
-3
spec/finders/pipelines_finder_spec.rb
spec/finders/pipelines_finder_spec.rb
+22
-23
No files found.
app/finders/pipelines_finder.rb
View file @
fd302061
...
...
@@ -102,7 +102,7 @@ class PipelinesFinder
def
order_and_sort
(
items
)
if
params
[
:order_by
].
present?
&&
params
[
:sort
].
present?
&&
items
.
column_names
.
include?
(
params
[
:order_by
])
&&
(
params
[
:sort
].
downcase
==
'asc'
||
params
[
:sort
].
downcase
==
'desc'
)
(
params
[
:sort
].
casecmp
(
'ASC'
)
||
params
[
:sort
].
casecmp
(
'DESC'
)
)
items
.
order
(
"
#{
params
[
:order_by
]
}
#{
params
[
:sort
]
}
"
)
else
items
.
order
(
id: :desc
)
...
...
lib/api/pipelines.rb
View file @
fd302061
...
...
@@ -16,14 +16,14 @@ 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:
[
'running'
,
'pending'
,
'success'
,
'failed'
,
'canceled'
,
'skipped'
]
,
optional
:status
,
type:
String
,
values:
%w(running pending success failed canceled skipped)
,
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'
optional
:username
,
type:
String
,
desc:
'The name of user who triggered pipelines'
optional
:order_by
,
type:
String
,
values:
[
'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'
optional
:sort
,
type:
String
,
values:
[
'asc'
,
'desc'
]
,
default:
'desc'
,
optional
:sort
,
type:
String
,
values:
%w(asc desc)
,
default:
'desc'
,
desc:
'The sort method which is combined with an order_by'
end
get
':id/pipelines'
do
...
...
spec/finders/pipelines_finder_spec.rb
View file @
fd302061
...
...
@@ -34,8 +34,7 @@ describe PipelinesFinder do
end
it
'orders in descending order on ID'
do
expected_ids
=
[
tag_pipeline
.
id
,
expected_ids
=
[
tag_pipeline
.
id
,
created_pipeline
.
id
,
pending_pipeline
.
id
,
running_pipeline
.
id
,
...
...
@@ -214,21 +213,21 @@ describe PipelinesFinder do
end
context
'when a order_by and sort are passed'
do
context
'when order by
star
ted_at asc'
do
context
'when order by
crea
ted_at asc'
do
let
(
:params
)
{
{
order_by:
'created_at'
,
sort:
'asc'
}
}
it
'sorts by
star
ted_at asc'
do
expect
ed_created_at
=
[
tag_pipeline
.
created_at
,
created_pipeline
.
created_at
,
pending_pipeline
.
created_at
,
running_pipeline
.
created_at
,
success_pipeline
.
created_at
,
failed_pipeline
.
created_at
,
canceled_pipeline
.
created_at
,
skipped_pipeline
.
created_at
,
yaml_errors_pipeline
.
created_at
].
sort
expect
(
subject
.
map
(
&
:created_at
)).
to
eq
expected_created_at
it
'sorts by
crea
ted_at asc'
do
expect
(
subject
.
first
).
to
eq
(
tag_pipeline
)
expect
(
subject
.
last
).
to
eq
(
yaml_errors_pipeline
)
end
end
context
'when order by created_at desc'
do
let
(
:params
)
{
{
order_by:
'created_at'
,
sort:
'desc'
}
}
it
'sorts by created_at desc'
do
expect
(
subject
.
first
).
to
eq
(
yaml_errors_pipeline
)
expect
(
subject
.
last
).
to
eq
(
tag_pipeline
)
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