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
42e11aa6
Commit
42e11aa6
authored
Jan 10, 2020
by
Andreas Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Let tie breaker order follow global sort direction
Related issue:
https://gitlab.com/gitlab-org/gitlab/issues/195881
parent
3bbbf60a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
1 deletion
+48
-1
changelogs/unreleased/ab-tie-breaker-order.yml
changelogs/unreleased/ab-tie-breaker-order.yml
+5
-0
lib/api/helpers.rb
lib/api/helpers.rb
+1
-1
spec/lib/api/helpers_spec.rb
spec/lib/api/helpers_spec.rb
+42
-0
No files found.
changelogs/unreleased/ab-tie-breaker-order.yml
0 → 100644
View file @
42e11aa6
---
title
:
Let tie breaker order follow primary sort direction (API)
merge_request
:
22795
author
:
type
:
changed
lib/api/helpers.rb
View file @
42e11aa6
...
...
@@ -316,7 +316,7 @@ module API
def
order_options_with_tie_breaker
order_options
=
{
params
[
:order_by
]
=>
params
[
:sort
]
}
order_options
[
'id'
]
||=
'de
sc'
order_options
[
'id'
]
||=
params
[
:sort
]
||
'a
sc'
order_options
end
...
...
spec/lib/api/helpers_spec.rb
View file @
42e11aa6
...
...
@@ -188,4 +188,46 @@ describe API::Helpers do
subject
.
track_event
(
'my_event'
,
category:
nil
)
end
end
describe
'#order_options_with_tie_breaker'
do
let
(
:subject
)
{
Class
.
new
.
include
(
described_class
).
new
.
order_options_with_tie_breaker
}
before
do
allow_any_instance_of
(
described_class
).
to
receive
(
:params
).
and_return
(
params
)
end
context
'with non-id order given'
do
context
'with ascending order'
do
let
(
:params
)
{
{
order_by:
'name'
,
sort:
'asc'
}
}
it
'adds id based ordering with same direction as primary order'
do
expect
(
subject
).
to
eq
({
'name'
=>
'asc'
,
'id'
=>
'asc'
})
end
end
context
'with descending order'
do
let
(
:params
)
{
{
order_by:
'name'
,
sort:
'desc'
}
}
it
'adds id based ordering with same direction as primary order'
do
expect
(
subject
).
to
eq
({
'name'
=>
'desc'
,
'id'
=>
'desc'
})
end
end
end
context
'with non-id order but no direction given'
do
let
(
:params
)
{
{
order_by:
'name'
}
}
it
'adds ID ASC order'
do
expect
(
subject
).
to
eq
({
'name'
=>
nil
,
'id'
=>
'asc'
})
end
end
context
'with id order given'
do
let
(
:params
)
{
{
order_by:
'id'
,
sort:
'asc'
}
}
it
'does not add an additional order'
do
expect
(
subject
).
to
eq
({
'id'
=>
'asc'
})
end
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