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
c35ca653
Commit
c35ca653
authored
Oct 02, 2018
by
Jarka Košanová
Committed by
Jose Vargas
Dec 05, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add spec for helper and simplify Issuable method
parent
eef6b238
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
14 deletions
+52
-14
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+10
-14
spec/helpers/sorting_helper_spec.rb
spec/helpers/sorting_helper_spec.rb
+42
-0
No files found.
app/models/concerns/issuable.rb
View file @
c35ca653
...
...
@@ -145,20 +145,16 @@ module Issuable
def
sort_by_attribute
(
method
,
excluded_labels:
[])
sorted
=
case
method
.
to_s
when
'downvotes_desc'
then
order_downvotes_desc
when
'label_priority'
then
order_labels_priority
(
excluded_labels:
excluded_labels
)
when
'label_priority_asc'
then
order_labels_priority
(
excluded_labels:
excluded_labels
)
when
'label_priority_desc'
then
order_labels_priority
(
'DESC'
,
excluded_labels:
excluded_labels
)
when
'milestone'
then
order_milestone_due_asc
when
'milestone_due_asc'
then
order_milestone_due_asc
when
'milestone_due_desc'
then
order_milestone_due_desc
when
'popularity'
then
order_upvotes_desc
when
'popularity_desc'
then
order_upvotes_desc
when
'popularity_asc'
then
order_upvotes_asc
when
'priority'
then
order_due_date_and_labels_priority
(
excluded_labels:
excluded_labels
)
when
'priority_asc'
then
order_due_date_and_labels_priority
(
excluded_labels:
excluded_labels
)
when
'priority_desc'
then
order_due_date_and_labels_priority
(
'DESC'
,
excluded_labels:
excluded_labels
)
when
'upvotes_desc'
then
order_upvotes_desc
when
'downvotes_desc'
then
order_downvotes_desc
when
'label_priority'
,
'label_priority_asc'
then
order_labels_priority
(
excluded_labels:
excluded_labels
)
when
'label_priority_desc'
then
order_labels_priority
(
'DESC'
,
excluded_labels:
excluded_labels
)
when
'milestone'
,
'milestone_due_asc'
then
order_milestone_due_asc
when
'milestone_due_desc'
then
order_milestone_due_desc
when
'popularity'
,
'popularity_desc'
then
order_upvotes_desc
when
'popularity_asc'
then
order_upvotes_asc
when
'priority'
,
'priority_asc'
then
order_due_date_and_labels_priority
(
excluded_labels:
excluded_labels
)
when
'priority_desc'
then
order_due_date_and_labels_priority
(
'DESC'
,
excluded_labels:
excluded_labels
)
when
'upvotes_desc'
then
order_upvotes_desc
else
order_by
(
method
)
end
...
...
spec/helpers/sorting_helper_spec.rb
0 → 100644
View file @
c35ca653
require
'spec_helper'
describe
SortingHelper
do
include
ApplicationHelper
include
IconsHelper
describe
'#issuable_sort_option_title'
do
it
'returns correct title for issuable_sort_option_overrides key'
do
expect
(
issuable_sort_option_title
(
'created_asc'
)).
to
eq
(
'Created date'
)
end
it
'returns correct title for a valid sort value'
do
expect
(
issuable_sort_option_title
(
'priority'
)).
to
eq
(
'Priority'
)
end
it
'returns nil for invalid sort value'
do
expect
(
issuable_sort_option_title
(
'invalid_key'
)).
to
eq
(
nil
)
end
end
describe
'#issuable_sort_direction_button'
do
before
do
allow
(
self
).
to
receive
(
:request
).
and_return
(
double
(
path:
'http://test.com'
))
end
it
'returns icon with sort-highest when sort is created_date'
do
expect
(
issuable_sort_direction_button
(
'created_date'
)).
to
include
(
'sort-highest'
)
end
it
'returns icon with sort-lowest when sort is asc'
do
expect
(
issuable_sort_direction_button
(
'created_asc'
)).
to
include
(
'sort-lowest'
)
end
it
'returns icon with sort-lowest when sorting by milestone'
do
expect
(
issuable_sort_direction_button
(
'milestone'
)).
to
include
(
'sort-lowest'
)
end
it
'returns icon with sort-lowest when sorting by due_date'
do
expect
(
issuable_sort_direction_button
(
'due_date'
)).
to
include
(
'sort-lowest'
)
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