Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
bdb9340e
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,发现更多精彩内容 >>
提交
bdb9340e
编写于
8月 11, 2014
作者:
D
Dmitriy Zaporozhets
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7385 from Razer6/fix_search_empty_project
Fix 500 on searching on empty project, restyle search page
上级
7122a823
f361be9e
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
61 addition
and
13 deletion
+61
-13
app/assets/stylesheets/generic/common.scss
app/assets/stylesheets/generic/common.scss
+15
-0
app/services/search/project_service.rb
app/services/search/project_service.rb
+7
-1
app/views/search/_project_results.html.haml
app/views/search/_project_results.html.haml
+12
-6
app/views/search/results/_empty.html.haml
app/views/search/results/_empty.html.haml
+4
-0
features/project/source/search_code.feature
features/project/source/search_code.feature
+8
-2
features/steps/project/search_code.rb
features/steps/project/search_code.rb
+8
-4
features/steps/shared/project.rb
features/steps/shared/project.rb
+7
-0
未找到文件。
app/assets/stylesheets/generic/common.scss
浏览文件 @
bdb9340e
...
...
@@ -341,3 +341,18 @@ table {
.footer-links
a
{
margin-right
:
15px
;
}
.search_box
{
position
:
relative
;
padding
:
30px
;
text-align
:
center
;
background-color
:
#F9F9F9
;
border
:
1px
solid
#DDDDDD
;
border-radius
:
0px
;
}
.search_glyph
{
color
:
#555
;
font-size
:
42px
;
}
app/services/search/project_service.rb
浏览文件 @
bdb9340e
...
...
@@ -12,7 +12,13 @@ module Search
return
result
unless
query
.
present?
if
params
[
:search_code
].
present?
blobs
=
project
.
repository
.
search_files
(
query
,
params
[
:repository_ref
])
unless
project
.
empty_repo?
if
!
@project
.
empty_repo?
blobs
=
project
.
repository
.
search_files
(
query
,
params
[
:repository_ref
])
else
blobs
=
Array
.
new
end
blobs
=
Kaminari
.
paginate_array
(
blobs
).
page
(
params
[
:page
]).
per
(
20
)
result
[
:blobs
]
=
blobs
result
[
:total_results
]
=
blobs
.
total_count
...
...
app/views/search/_project_results.html.haml
浏览文件 @
bdb9340e
...
...
@@ -9,10 +9,16 @@
.search_results
-
if
params
[
:search_code
].
present?
.blob-results
=
render
partial:
"search/results/blob"
,
collection:
@search_results
[
:blobs
]
=
paginate
@search_results
[
:blobs
],
theme:
'gitlab'
-
if
!
@search_results
[
:blobs
].
empty?
=
render
partial:
"search/results/blob"
,
collection:
@search_results
[
:blobs
]
=
paginate
@search_results
[
:blobs
],
theme:
'gitlab'
-
else
=
render
partial:
"search/results/empty"
,
:locals
=>
{
message:
"We couldn't find any matching code"
}
-
else
%ul
.bordered-list
=
render
partial:
"search/results/merge_request"
,
collection:
@search_results
[
:merge_requests
]
=
render
partial:
"search/results/issue"
,
collection:
@search_results
[
:issues
]
=
render
partial:
"search/results/note"
,
collection:
@search_results
[
:notes
]
-
if
(
@search_results
[
:merge_requests
]
||
@search_results
[
:issues
]
||
@search_results
[
:notes
]).
length
>
0
%ul
.bordered-list
=
render
partial:
"search/results/merge_request"
,
collection:
@search_results
[
:merge_requests
]
=
render
partial:
"search/results/issue"
,
collection:
@search_results
[
:issues
]
=
render
partial:
"search/results/note"
,
collection:
@search_results
[
:notes
]
-
else
=
render
partial:
"search/results/empty"
,
:locals
=>
{
message:
"We couldn't find any issues, merge requests or notes"
}
app/views/search/results/_empty.html.haml
0 → 100644
浏览文件 @
bdb9340e
.search_box
.search_glyph
%span
.icon-search
%h4
#{
message
}
features/project/source/search_code.feature
浏览文件 @
bdb9340e
Feature
:
Project Search code
Background
:
Given
I sign in as a user
And
I own project
"Shop"
Given
I visit project source page
Scenario
:
Search for term "coffee"
Given
I own project
"Shop"
And
I visit project source page
When
I search for term
"coffee"
Then
I should see files from repository containing
"coffee"
Scenario
:
Search on empty project
Given
I own an empty project
And
I visit my project's home page
When
I search for term
"coffee"
Then
I should see empty result
features/steps/project/search_code.rb
浏览文件 @
bdb9340e
...
...
@@ -3,14 +3,18 @@ class ProjectSearchCode < Spinach::FeatureSteps
include
SharedProject
include
SharedPaths
When
'I search for term "coffee"'
do
step
'I search for term "coffee"'
do
fill_in
"search"
,
with:
"coffee"
click_button
"Go"
click_link
'Repository Code'
end
Then
'I should see files from repository containing "coffee"'
do
page
.
should
have_content
"coffee"
page
.
should
have_content
" CONTRIBUTING.md"
step
'I should see files from repository containing "coffee"'
do
page
.
should
have_content
'coffee'
page
.
should
have_content
'CONTRIBUTING.md'
end
step
'I should see empty result'
do
page
.
should
have_content
"We couldn't find any matching code"
end
end
features/steps/shared/project.rb
浏览文件 @
bdb9340e
...
...
@@ -21,6 +21,13 @@ module SharedProject
@project
.
team
<<
[
@user
,
:master
]
end
# Create an empty project without caring about the name
And
'I own an empty project'
do
@project
=
create
(
:empty_project
,
name:
'Empty Project'
,
namespace:
@user
.
namespace
)
@project
.
team
<<
[
@user
,
:master
]
end
And
'project "Shop" has push event'
do
@project
=
Project
.
find_by
(
name:
"Shop"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录