Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
e864bdf2
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,发现更多精彩内容 >>
提交
e864bdf2
编写于
6月 10, 2016
作者:
F
Fatih Acet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix specs and add new tests.
上级
639347ba
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
64 addition
and
44 deletion
+64
-44
spec/features/search_spec.rb
spec/features/search_spec.rb
+2
-2
spec/javascripts/search_autocomplete_spec.js.coffee
spec/javascripts/search_autocomplete_spec.js.coffee
+62
-42
未找到文件。
spec/features/search_spec.rb
浏览文件 @
e864bdf2
...
...
@@ -68,7 +68,7 @@ describe "Search", feature: true do
it
'should show category search dropdown'
do
page
.
find
(
'#search'
).
click
expect
(
page
).
to
have_selector
(
'.dropdown-header'
,
text:
/
go to in
#{
project
.
name
}
/i
)
expect
(
page
).
to
have_selector
(
'.dropdown-header'
,
text:
/
#{
project
.
name
}
/i
)
end
end
...
...
@@ -119,7 +119,7 @@ describe "Search", feature: true do
end
it
'should not display the category search dropdown'
do
expect
(
page
).
not_to
have_selector
(
'.dropdown-header'
,
text:
/
go to in
#{
project
.
name
}
/i
)
expect
(
page
).
not_to
have_selector
(
'.dropdown-header'
,
text:
/
#{
project
.
name
}
/i
)
end
end
end
...
...
spec/javascripts/search_autocomplete_spec.js.coffee
浏览文件 @
e864bdf2
...
...
@@ -13,18 +13,33 @@ window.gon.current_user_id = userId
dashboardIssuesPath
=
'/dashboard/issues'
dashboardMRsPath
=
'/dashboard/merge_requests'
projectIssuesPath
=
"/gitlab-org/gitlab-ce/issues"
projectMRsPath
=
"/gitlab-org/gitlab-ce/merge_requests"
projectIssuesPath
=
'/gitlab-org/gitlab-ce/issues'
projectMRsPath
=
'/gitlab-org/gitlab-ce/merge_requests'
groupIssuesPath
=
'/groups/gitlab-org/issues'
groupMRsPath
=
'/groups/gitlab-org/merge_requests'
projectName
=
'GitLab Community Edition'
groupName
=
'Gitlab Org'
# Add required attributes to body before starting the test.
addBodyAttributes
=
(
page
=
'groups'
)
->
# section would be dashboard|group|project
addBodyAttributes
=
(
section
=
'dashboard'
)
->
$body
=
$
'body'
$
(
'body'
).
removeAttr
'data-page'
$
(
'body'
).
removeAttr
'data-project'
$body
.
removeAttr
'data-page'
$body
.
removeAttr
'data-project'
$body
.
removeAttr
'data-group'
$
(
'body'
).
data
'page'
,
"
#{
page
}
:show"
$
(
'body'
).
data
'project'
,
'gitlab-ce'
switch
section
when
'dashboard'
$body
.
data
'page'
,
'root:index'
when
'group'
$body
.
data
'page'
,
'groups:show'
$body
.
data
'group'
,
'gitlab-org'
when
'project'
$body
.
data
'page'
,
'projects:show'
$body
.
data
'project'
,
'gitlab-ce'
# Mock `gl` object in window for dashboard specific page. App code will need it.
...
...
@@ -47,7 +62,27 @@ mockProjectOptions = ->
projectName
:
projectName
assertLinks
=
(
list
,
a1
,
a2
,
a3
,
a4
)
->
mockGroupOptions
=
->
window
.
gl
or=
{}
window
.
gl
.
groupOptions
=
'gitlab-org'
:
issuesPath
:
groupIssuesPath
mrPath
:
groupMRsPath
projectName
:
groupName
assertLinks
=
(
list
,
issuesPath
,
mrsPath
)
->
issuesAssignedToMeLink
=
"
#{
issuesPath
}
/?assignee_id=
#{
userId
}
"
issuesIHaveCreatedLink
=
"
#{
issuesPath
}
/?author_id=
#{
userId
}
"
mrsAssignedToMeLink
=
"
#{
mrsPath
}
/?assignee_id=
#{
userId
}
"
mrsIHaveCreatedLink
=
"
#{
mrsPath
}
/?author_id=
#{
userId
}
"
a1
=
"a[href='
#{
issuesAssignedToMeLink
}
']"
a2
=
"a[href='
#{
issuesIHaveCreatedLink
}
']"
a3
=
"a[href='
#{
mrsAssignedToMeLink
}
']"
a4
=
"a[href='
#{
mrsIHaveCreatedLink
}
']"
expect
(
list
.
find
(
a1
).
length
).
toBe
1
expect
(
list
.
find
(
a1
).
text
()).
toBe
' Issues assigned to me '
...
...
@@ -62,7 +97,6 @@ assertLinks = (list, a1, a2, a3, a4) ->
expect
(
list
.
find
(
a4
).
text
()).
toBe
" Merge requests I've created "
describe
'Search autocomplete dropdown'
,
->
fixture
.
preload
'search_autocomplete.html'
...
...
@@ -77,53 +111,39 @@ describe 'Search autocomplete dropdown', ->
addBodyAttributes
()
mockDashboardOptions
()
# Focus input to show dropdown list.
widget
.
searchInput
.
focus
()
w
=
widget
.
wrap
.
find
'.dropdown-menu
'
l
=
w
.
find
'ul'
list
=
widget
.
wrap
.
find
(
'.dropdown-menu'
).
find
'ul
'
assertLinks
list
,
dashboardIssuesPath
,
dashboardMRsPath
# # Expect dropdown and dropdown header
expect
(
w
.
find
(
'.dropdown-header'
).
text
()).
toBe
'Go to in Dashboard'
# Create links then assert link urls and inner texts
issuesAssignedToMeLink
=
"
#{
dashboardIssuesPath
}
/?assignee_id=
#{
userId
}
"
issuesIHaveCreatedLink
=
"
#{
dashboardIssuesPath
}
/?author_id=
#{
userId
}
"
mrsAssignedToMeLink
=
"
#{
dashboardMRsPath
}
/?assignee_id=
#{
userId
}
"
mrsIHaveCreatedLink
=
"
#{
dashboardMRsPath
}
/?author_id=
#{
userId
}
"
it
'should show Group specific dropdown menu'
,
->
a1
=
"a[href='
#{
issuesAssignedToMeLink
}
']"
a2
=
"a[href='
#{
issuesIHaveCreatedLink
}
']"
a3
=
"a[href='
#{
mrsAssignedToMeLink
}
']"
a4
=
"a[href='
#{
mrsIHaveCreatedLink
}
']"
addBodyAttributes
'group'
mockGroupOptions
()
widget
.
searchInput
.
focus
()
assertLinks
l
,
a1
,
a2
,
a3
,
a4
list
=
widget
.
wrap
.
find
(
'.dropdown-menu'
).
find
'ul'
assertLinks
list
,
groupIssuesPath
,
groupMRsPath
it
'should show Project specific dropdown menu'
,
->
addBodyAttributes
'project
s
'
addBodyAttributes
'project'
mockProjectOptions
()
# Focus input to show dropdown list.
widget
.
searchInput
.
focus
()
w
=
widget
.
wrap
.
find
'.dropdown-menu
'
l
=
w
.
find
'ul'
list
=
widget
.
wrap
.
find
(
'.dropdown-menu'
).
find
'ul
'
assertLinks
list
,
projectIssuesPath
,
projectMRsPath
# Expect dropdown and dropdown header
expect
(
w
.
find
(
'.dropdown-header'
).
text
()).
toBe
"Go to in
#{
projectName
}
"
# Create links then verify link urls and inner texts
issuesAssignedToMeLink
=
"
#{
projectIssuesPath
}
/?assignee_id=
#{
userId
}
"
issuesIHaveCreatedLink
=
"
#{
projectIssuesPath
}
/?author_id=
#{
userId
}
"
mrsAssignedToMeLink
=
"
#{
projectMRsPath
}
/?assignee_id=
#{
userId
}
"
mrsIHaveCreatedLink
=
"
#{
projectMRsPath
}
/?author_id=
#{
userId
}
"
it
'should not show category related menu if there is text in the input'
,
->
a
1
=
"a[href='
#{
issuesAssignedToMeLink
}
']"
a2
=
"a[href='
#{
issuesIHaveCreatedLink
}
']"
a3
=
"a[href='
#{
mrsAssignedToMeLink
}
']"
a4
=
"a[href='
#{
mrsIHaveCreatedLink
}
']"
a
ddBodyAttributes
'project'
mockProjectOptions
()
widget
.
searchInput
.
val
'help'
widget
.
searchInput
.
focus
()
assertLinks
l
,
a1
,
a2
,
a3
,
a4
list
=
widget
.
wrap
.
find
(
'.dropdown-menu'
).
find
'ul'
link
=
"a[href='
#{
projectIssuesPath
}
/?assignee_id=
#{
userId
}
']"
expect
(
list
.
find
(
link
).
length
).
toBe
0
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录