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
305f4031
Commit
305f4031
authored
Jun 17, 2019
by
Ezekiel Kigbo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added tests for current behaviour
parent
d73f4264
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
119 additions
and
10 deletions
+119
-10
app/helpers/sorting_helper.rb
app/helpers/sorting_helper.rb
+5
-10
spec/helpers/sorting_helper_spec.rb
spec/helpers/sorting_helper_spec.rb
+114
-0
No files found.
app/helpers/sorting_helper.rb
View file @
305f4031
...
...
@@ -38,14 +38,12 @@ module SortingHelper
# https://gitlab.com/gitlab-org/gitlab-ce/issues/60798
# https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/11209#note_162234858
def
old_projects_sort_options_hash
options
=
{
sort_value_latest_activity
=>
sort_title_latest_activity
,
sort_value_name
=>
sort_title_name
,
options
=
projects_sort_common_options_hash
.
merge
({
sort_value_oldest_activity
=>
sort_title_oldest_activity
,
sort_value_oldest_created
=>
sort_title_oldest_created
,
sort_value_recently_created
=>
sort_title_recently_created
,
sort_value_stars_desc
=>
sort_title_most_stars
}
}
)
if
current_controller?
(
'admin/projects'
)
options
[
sort_value_largest_repo
]
=
sort_title_largest_repo
...
...
@@ -64,16 +62,12 @@ module SortingHelper
end
def
projects_sort_option_titles
{
sort_value_latest_activity
=>
sort_title_latest_activity
,
sort_value_recently_created
=>
sort_title_created_date
,
sort_value_name
=>
sort_title_name
,
sort_value_stars_desc
=>
sort_title_stars
,
projects_sort_common_options_hash
.
merge
({
sort_value_oldest_activity
=>
sort_title_latest_activity
,
sort_value_oldest_created
=>
sort_title_created_date
,
sort_value_name_desc
=>
sort_title_name
,
sort_value_stars_asc
=>
sort_title_stars
}
}
)
end
def
projects_reverse_sort_options_hash
...
...
@@ -237,6 +231,7 @@ module SortingHelper
end
end
# TODO: dedupicate issuable and project sort direction
def
project_sort_direction_button
(
sort_value
)
link_class
=
'btn btn-default has-tooltip reverse-sort-btn qa-reverse-sort'
reverse_sort
=
projects_reverse_sort_options_hash
[
sort_value
]
...
...
spec/helpers/sorting_helper_spec.rb
View file @
305f4031
...
...
@@ -4,6 +4,7 @@ require 'spec_helper'
describe
SortingHelper
do
include
ApplicationHelper
include
IconsHelper
include
ExploreHelper
describe
'#issuable_sort_option_title'
do
it
'returns correct title for issuable_sort_option_overrides key'
do
...
...
@@ -44,4 +45,117 @@ describe SortingHelper do
expect
(
issuable_sort_direction_button
(
'due_date'
)).
to
include
(
'sort-lowest'
)
end
end
# TODO: need separate tests for /admin/projects and /projects
# TODO: should this be renamed to `projects_sort_option_title??` ... maybe not
def
stub_controller_path
(
value
)
allow
(
helper
.
controller
).
to
receive
(
:controller_path
).
and_return
(
value
)
end
def
project_common_options
()
{
sort_value_latest_activity
=>
sort_title_latest_activity
,
sort_value_recently_created
=>
sort_title_created_date
,
sort_value_name
=>
sort_title_name
,
sort_value_stars_desc
=>
sort_title_stars
}
end
def
admin_additional_project_options
()
{
sort_value_recently_created
=>
sort_title_recently_created
,
sort_value_largest_repo
=>
sort_title_largest_repo
,
sort_value_oldest_activity
=>
sort_title_oldest_activity
,
sort_value_oldest_created
=>
sort_title_oldest_created
,
sort_value_stars_desc
=>
sort_title_most_stars
}
end
describe
'with `admin/projects` controller'
,
:focus
do
before
do
stub_controller_path
(
'admin/projects'
)
end
describe
'#projects_sort_options_hash'
do
it
'returns a hash of available sorting options'
do
hash
=
projects_sort_options_hash
admin_options
=
project_common_options
.
merge
(
admin_additional_project_options
)
expect
(
hash
).
to
eq
(
admin_options
)
end
end
end
describe
'with `projects` controller'
,
:focus
do
before
do
stub_controller_path
(
'projects'
)
end
describe
'#projects_sort_options_hash'
do
it
'returns a hash of available sorting options'
do
hash
=
projects_sort_options_hash
common_options
=
project_common_options
admin_options
=
admin_additional_project_options
common_with_different_values
=
[
sort_value_recently_created
,
sort_value_stars_desc
]
common_options
.
each
do
|
key
,
opt
|
expect
(
hash
).
to
include
(
key
)
expect
(
hash
[
key
]).
to
eq
(
opt
)
end
admin_options
.
each
do
|
key
,
opt
|
if
common_with_different_values
.
include?
(
key
)
expect
(
hash
[
key
]).
not_to
eq
(
opt
)
else
expect
(
hash
).
not_to
include
(
key
)
end
end
end
end
describe
'#projects_reverse_sort_options_hash'
do
it
'returns a reversed hash of available sorting options'
do
reverse_hash
=
projects_reverse_sort_options_hash
options
=
{
sort_value_latest_activity
=>
sort_value_oldest_activity
,
sort_value_recently_created
=>
sort_value_oldest_created
,
sort_value_name
=>
sort_value_name_desc
,
sort_value_stars_desc
=>
sort_value_stars_asc
,
sort_value_oldest_activity
=>
sort_value_latest_activity
,
sort_value_oldest_created
=>
sort_value_recently_created
,
sort_value_name_desc
=>
sort_value_name
,
sort_value_stars_asc
=>
sort_value_stars_desc
}
options
.
each
do
|
key
,
opt
|
expect
(
reverse_hash
).
to
include
(
key
)
expect
(
reverse_hash
[
key
]).
to
eq
(
opt
)
end
end
end
end
describe
'#project_sort_direction_button'
,
:focus
do
before
do
allow
(
self
).
to
receive
(
:request
).
and_return
(
double
(
path:
'http://test.com'
,
query_parameters:
{
label_name:
'test_label'
}))
end
it
'returns icon with sort-highest when sort is created_date'
do
expect
(
project_sort_direction_button
(
'created_date'
)).
to
include
(
'sort-highest'
)
end
it
'returns icon with sort-lowest when sort is asc'
do
expect
(
project_sort_direction_button
(
'created_asc'
)).
to
include
(
'sort-lowest'
)
end
it
'returns icon with sort-lowest when sorting by milestone'
do
expect
(
project_sort_direction_button
(
'milestone'
)).
to
include
(
'sort-lowest'
)
end
it
'returns icon with sort-lowest when sorting by due_date'
do
expect
(
project_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