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
da7e14c8
Commit
da7e14c8
authored
Jul 28, 2014
by
Robert Schilling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix searching on empty project, prevent 500
Fix hound
parent
9d3e384a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
9 deletions
+35
-9
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
+5
-2
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
No files found.
app/services/search/project_service.rb
View file @
da7e14c8
...
...
@@ -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
View file @
da7e14c8
...
...
@@ -9,8 +9,11 @@
.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
%span
We couldn't find any matching code
-
else
%ul
.bordered-list
=
render
partial:
"search/results/merge_request"
,
collection:
@search_results
[
:merge_requests
]
...
...
features/project/source/search_code.feature
View file @
da7e14c8
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
View file @
da7e14c8
...
...
@@ -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
View file @
da7e14c8
...
...
@@ -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"
)
...
...
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