Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
305f4031
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
305f4031
编写于
6月 17, 2019
作者:
E
Ezekiel Kigbo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added tests for current behaviour
上级
d73f4264
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
119 addition
and
10 deletion
+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
未找到文件。
app/helpers/sorting_helper.rb
浏览文件 @
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
浏览文件 @
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
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录