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
f2711628
Commit
f2711628
authored
Jul 09, 2019
by
Ezekiel Kigbo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor review cleanup
Minor refactor specs
parent
b054a961
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
62 deletions
+48
-62
app/helpers/sorting_helper.rb
app/helpers/sorting_helper.rb
+1
-1
spec/helpers/sorting_helper_spec.rb
spec/helpers/sorting_helper_spec.rb
+47
-61
No files found.
app/helpers/sorting_helper.rb
View file @
f2711628
...
...
@@ -31,7 +31,7 @@ module SortingHelper
end
def
projects_sort_options_hash
use_old_sorting
=
!
Feature
.
en
abled?
(
:project_list_filter_bar
)
||
current_controller?
(
'admin/projects'
)
use_old_sorting
=
Feature
.
dis
abled?
(
:project_list_filter_bar
)
||
current_controller?
(
'admin/projects'
)
options
=
{
sort_value_latest_activity
=>
sort_title_latest_activity
,
...
...
spec/helpers/sorting_helper_spec.rb
View file @
f2711628
...
...
@@ -70,8 +70,6 @@ describe SortingHelper do
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
({
sort_value_oldest_activity
=>
sort_title_oldest_activity
,
sort_value_oldest_created
=>
sort_title_oldest_created
,
...
...
@@ -79,7 +77,8 @@ describe SortingHelper do
sort_value_stars_desc
=>
sort_title_most_stars
,
sort_value_largest_repo
=>
sort_title_largest_repo
})
expect
(
hash
).
to
eq
(
admin_options
)
expect
(
projects_sort_options_hash
).
to
eq
(
admin_options
)
end
end
end
...
...
@@ -91,58 +90,60 @@ describe SortingHelper do
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
common_options
.
each
do
|
key
,
opt
|
expect
(
hash
).
to
include
(
key
)
expect
(
hash
[
key
]).
to
eq
(
opt
)
end
expect
(
projects_sort_options_hash
).
to
include
(
project_common_options
)
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
)
context
'returns a reversed hash of available sorting options'
do
using
RSpec
::
Parameterized
::
TableSyntax
where
(
:sort_key
,
:reverse_sort_title
)
do
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
end
with_them
do
it
do
reverse_hash
=
projects_reverse_sort_options_hash
expect
(
reverse_hash
).
to
include
(
sort_key
)
expect
(
reverse_hash
[
sort_key
]).
to
eq
(
reverse_sort_title
)
end
end
end
end
describe
'#project_sort_direction_button'
do
it
'returns the correct icon for each sort option'
do
context
'returns the correct icon for each sort option'
do
using
RSpec
::
Parameterized
::
TableSyntax
sort_lowest_icon
=
'sort-lowest'
sort_highest_icon
=
'sort-highest'
sort_options_icons
=
{
sort_value_latest_activity
=>
sort_highest_icon
,
sort_value_recently_created
=>
sort_highest_icon
,
sort_value_name_desc
=>
sort_highest_icon
,
sort_value_stars_desc
=>
sort_highest_icon
,
sort_value_oldest_activity
=>
sort_lowest_icon
,
sort_value_oldest_created
=>
sort_lowest_icon
,
sort_value_name
=>
sort_lowest_icon
,
sort_value_stars_asc
=>
sort_lowest_icon
}
sort_options_icons
.
each
do
|
selected_sort
,
icon
|
set_sorting_url
selected_sort
where
(
:selected_sort
,
:icon
)
do
sort_value_latest_activity
|
sort_highest_icon
sort_value_recently_created
|
sort_highest_icon
sort_value_name_desc
|
sort_highest_icon
sort_value_stars_desc
|
sort_highest_icon
sort_value_oldest_activity
|
sort_lowest_icon
sort_value_oldest_created
|
sort_lowest_icon
sort_value_name
|
sort_lowest_icon
sort_value_stars_asc
|
sort_lowest_icon
end
with_them
do
it
do
set_sorting_url
selected_sort
expect
(
project_sort_direction_button
(
selected_sort
)).
to
include
(
icon
)
expect
(
project_sort_direction_button
(
selected_sort
)).
to
include
(
icon
)
end
end
end
...
...
@@ -159,25 +160,14 @@ describe SortingHelper do
describe
'#projects_sort_option_titles'
do
it
'returns a hash of titles for the sorting options'
do
titles
=
projects_sort_option_titles
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
,
options
=
project_common_options
.
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
}
expect
(
titles
.
length
).
to
eq
(
options
.
length
)
})
titles
.
each
do
|
key
,
opt
|
expect
(
options
).
to
include
(
key
)
expect
(
options
[
key
]).
to
eq
(
opt
)
end
expect
(
projects_sort_option_titles
).
to
eq
(
options
)
end
end
...
...
@@ -188,7 +178,6 @@ describe SortingHelper do
describe
'#projects_sort_options_hash'
do
it
'returns a hash of available sorting options'
do
hash
=
projects_sort_options_hash
options
=
project_common_options
.
merge
({
sort_value_oldest_activity
=>
sort_title_oldest_activity
,
sort_value_oldest_created
=>
sort_title_oldest_created
,
...
...
@@ -196,10 +185,7 @@ describe SortingHelper do
sort_value_stars_desc
=>
sort_title_most_stars
})
options
.
each
do
|
key
,
opt
|
expect
(
hash
).
to
include
(
key
)
expect
(
hash
[
key
]).
to
eq
(
opt
)
end
expect
(
projects_sort_options_hash
).
to
eq
(
options
)
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