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
cd7b81bd
Commit
cd7b81bd
authored
Jun 02, 2021
by
Pedro Pombeiro
Committed by
Adam Hegyi
Jun 14, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address MR review comments
parent
53d0a632
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
29 deletions
+21
-29
app/finders/ci/runners_finder.rb
app/finders/ci/runners_finder.rb
+4
-6
spec/finders/ci/runners_finder_spec.rb
spec/finders/ci/runners_finder_spec.rb
+17
-23
No files found.
app/finders/ci/runners_finder.rb
View file @
cd7b81bd
...
...
@@ -4,6 +4,9 @@ module Ci
class
RunnersFinder
<
UnionFinder
include
Gitlab
::
Allowable
ALLOWED_SORTS
=
%w[contacted_asc contacted_desc created_at_asc created_at_desc]
.
freeze
DEFAULT_SORT
=
'created_date'
def
initialize
(
current_user
:,
group:
nil
,
params
:)
@params
=
params
@group
=
group
...
...
@@ -24,12 +27,7 @@ module Ci
end
def
sort_key
case
@params
[
:sort
]
when
'contacted_asc'
,
'contacted_desc'
,
'created_at_asc'
,
'created_at_desc'
@params
[
:sort
]
else
'created_date'
end
ALLOWED_SORTS
.
include?
(
@params
[
:sort
])
?
@params
[
:sort
]
:
DEFAULT_SORT
end
private
...
...
spec/finders/ci/runners_finder_spec.rb
View file @
cd7b81bd
...
...
@@ -59,27 +59,23 @@ RSpec.describe Ci::RunnersFinder do
described_class
.
new
(
current_user:
admin
,
params:
params
).
execute
end
context
'without sort param'
do
let
(
:params
)
{
{}
}
shared_examples
'sorts by created_at descending'
do
it
'sorts by created_at descending'
do
is_expected
.
to
eq
[
runner3
,
runner2
,
runner1
]
end
end
context
'with
sort param equal to created_date
'
do
let
(
:params
)
{
{
sort:
'created_date'
}
}
context
'with
out sort param
'
do
let
(
:params
)
{
{}
}
it
'sorts by created_at descending'
do
is_expected
.
to
eq
[
runner3
,
runner2
,
runner1
]
end
it_behaves_like
'sorts by created_at descending'
end
context
'with sort param equal to created_at_desc'
do
let
(
:params
)
{
{
sort:
'created_at_desc'
}
}
%w(created_date created_at_desc)
.
each
do
|
sort
|
context
"with sort param equal to
#{
sort
}
"
do
let
(
:params
)
{
{
sort:
sort
}
}
it
'sorts by created_at descending'
do
is_expected
.
to
eq
[
runner3
,
runner2
,
runner1
]
it_behaves_like
'sorts by created_at descending'
end
end
...
...
@@ -91,21 +87,19 @@ RSpec.describe Ci::RunnersFinder do
end
end
context
'by contacted_at'
do
context
'with sort param equal to contacted_asc'
do
let
(
:params
)
{
{
sort:
'contacted_asc'
}
}
context
'with sort param equal to contacted_asc'
do
let
(
:params
)
{
{
sort:
'contacted_asc'
}
}
it
'sorts by contacted_at ascending'
do
is_expected
.
to
eq
[
runner2
,
runner3
,
runner1
]
end
it
'sorts by contacted_at ascending'
do
is_expected
.
to
eq
[
runner2
,
runner3
,
runner1
]
end
end
context
'with sort param equal to contacted_desc'
do
let
(
:params
)
{
{
sort:
'contacted_desc'
}
}
context
'with sort param equal to contacted_desc'
do
let
(
:params
)
{
{
sort:
'contacted_desc'
}
}
it
'sorts by contacted_at descending'
do
is_expected
.
to
eq
[
runner1
,
runner3
,
runner2
]
end
it
'sorts by contacted_at descending'
do
is_expected
.
to
eq
[
runner1
,
runner3
,
runner2
]
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