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
03cff6b7
Commit
03cff6b7
authored
Aug 07, 2018
by
Chantal Rollison
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modified find project method to return nil if project not found
parent
dd38a810
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
1 deletion
+57
-1
app/views/search/results/_blob.html.haml
app/views/search/results/_blob.html.haml
+2
-0
ee/app/helpers/ee/search_helper.rb
ee/app/helpers/ee/search_helper.rb
+1
-1
ee/changelogs/unreleased/ccr-5300-elasticsearch_index.yml
ee/changelogs/unreleased/ccr-5300-elasticsearch_index.yml
+5
-0
ee/spec/features/search/elastic/global_search_spec.rb
ee/spec/features/search/elastic/global_search_spec.rb
+24
-0
ee/spec/helpers/search_helper_spec.rb
ee/spec/helpers/search_helper_spec.rb
+25
-0
No files found.
app/views/search/results/_blob.html.haml
View file @
03cff6b7
-
project
=
find_project_for_result_blob
(
blob
)
-
return
unless
project
-
file_name
,
blob
=
parse_search_result
(
blob
)
-
blob_link
=
project_blob_path
(
project
,
tree_join
(
blob
.
ref
,
file_name
))
...
...
ee/app/helpers/ee/search_helper.rb
View file @
03cff6b7
...
...
@@ -11,7 +11,7 @@ module EE
override
:find_project_for_result_blob
def
find_project_for_result_blob
(
result
)
super
||
::
Project
.
find
(
result
[
'_parent'
])
super
||
::
Project
.
find
_by
(
id:
result
[
'_parent'
])
end
override
:parse_search_result
...
...
ee/changelogs/unreleased/ccr-5300-elasticsearch_index.yml
0 → 100644
View file @
03cff6b7
---
title
:
Don't show search results for projects that have been deleted when using elastic search
merge_request
:
6830
author
:
type
:
fixed
ee/spec/features/search/elastic/global_search_spec.rb
View file @
03cff6b7
...
...
@@ -36,6 +36,8 @@ describe 'Global elastic search' do
end
describe
'I search through the blobs'
do
let
(
:project_2
)
{
create
(
:project
,
:repository
,
:wiki_repo
)
}
before
do
project
.
repository
.
index_blobs
...
...
@@ -54,6 +56,28 @@ describe 'Global elastic search' do
expect
(
page
).
to
have_selector
(
"span.line[lang='javascript']"
)
end
it
'Ignores nonexistent projects from stale index'
do
stub_ee_application_setting
(
elasticsearch_search:
true
,
elasticsearch_indexing:
true
)
project_2
.
repository
.
create_file
(
user
,
'thing.txt'
,
' function application.js '
,
message:
'supercalifragilisticexpialidocious'
,
branch_name:
'master'
)
project_2
.
repository
.
index_blobs
Gitlab
::
Elastic
::
Helper
.
refresh_index
project_2
.
destroy
visit
dashboard_projects_path
fill_in
"search"
,
with:
"application.js"
click_button
"Go"
expect
(
page
).
not_to
have_content
'supercalifragilisticexpialidocious'
end
end
describe
'I search through the wiki blobs'
do
...
...
ee/spec/helpers/search_helper_spec.rb
View file @
03cff6b7
...
...
@@ -2,6 +2,8 @@ require 'spec_helper'
describe
SearchHelper
do
describe
'#parse_search_result_from_elastic'
do
let
(
:user
)
{
create
(
:user
)
}
before
do
stub_ee_application_setting
(
elasticsearch_search:
true
,
elasticsearch_indexing:
true
)
Gitlab
::
Elastic
::
Helper
.
create_empty_index
...
...
@@ -32,5 +34,28 @@ describe SearchHelper do
expect
(
parsed_result
.
startline
).
to
eq
(
2
)
expect
(
parsed_result
.
data
).
to
include
(
"Popen"
)
end
it
'does not return project that does not exist'
do
Gitlab
::
Elastic
::
Helper
.
create_empty_index
@project_2
=
create
:project
,
:repository
@project_2
.
repository
.
create_file
(
user
,
'thing.txt'
,
' function application.js '
,
message:
'Find me'
,
branch_name:
'master'
)
@project_2
.
repository
.
index_blobs
Gitlab
::
Elastic
::
Helper
.
refresh_index
@project_2
.
destroy
blob
=
{
_parent:
@project_2
.
id
}
result
=
find_project_for_result_blob
(
blob
)
expect
(
result
).
to
be
(
nil
)
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