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
7f32ad70
Commit
7f32ad70
authored
Apr 03, 2017
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix blob highlighting in search
parent
872b3215
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
4 deletions
+35
-4
changelogs/unreleased/30400-fix-blob-highlighting-in-search.yml
...logs/unreleased/30400-fix-blob-highlighting-in-search.yml
+4
-0
lib/gitlab/project_search_results.rb
lib/gitlab/project_search_results.rb
+1
-1
lib/gitlab/search_results.rb
lib/gitlab/search_results.rb
+21
-0
spec/features/search_spec.rb
spec/features/search_spec.rb
+3
-1
spec/lib/gitlab/project_search_results_spec.rb
spec/lib/gitlab/project_search_results_spec.rb
+6
-2
No files found.
changelogs/unreleased/30400-fix-blob-highlighting-in-search.yml
0 → 100644
View file @
7f32ad70
---
title
:
Fix blob highlighting in search
merge_request
:
10420
author
:
lib/gitlab/project_search_results.rb
View file @
7f32ad70
...
@@ -62,7 +62,7 @@ module Gitlab
...
@@ -62,7 +62,7 @@ module Gitlab
data
<<
line
.
sub
(
ref
,
''
).
sub
(
filename
,
''
).
sub
(
/^:-\d+-/
,
''
).
sub
(
/^::\d+:/
,
''
)
data
<<
line
.
sub
(
ref
,
''
).
sub
(
filename
,
''
).
sub
(
/^:-\d+-/
,
''
).
sub
(
/^::\d+:/
,
''
)
end
end
OpenStruct
.
new
(
FoundBlob
.
new
(
filename:
filename
,
filename:
filename
,
basename:
basename
,
basename:
basename
,
ref:
ref
,
ref:
ref
,
...
...
lib/gitlab/search_results.rb
View file @
7f32ad70
module
Gitlab
module
Gitlab
class
SearchResults
class
SearchResults
class
FoundBlob
attr_reader
:id
,
:filename
,
:basename
,
:ref
,
:startline
,
:data
def
initialize
(
opts
=
{})
@id
=
opts
.
fetch
(
:id
,
nil
)
@filename
=
opts
.
fetch
(
:filename
,
nil
)
@basename
=
opts
.
fetch
(
:basename
,
nil
)
@ref
=
opts
.
fetch
(
:ref
,
nil
)
@startline
=
opts
.
fetch
(
:startline
,
nil
)
@data
=
opts
.
fetch
(
:data
,
nil
)
end
def
path
filename
end
def
no_highlighting?
false
end
end
attr_reader
:current_user
,
:query
attr_reader
:current_user
,
:query
# Limit search results by passed projects
# Limit search results by passed projects
...
...
spec/features/search_spec.rb
View file @
7f32ad70
...
@@ -119,13 +119,15 @@ describe "Search", feature: true do
...
@@ -119,13 +119,15 @@ describe "Search", feature: true do
visit
namespace_project_path
(
project
.
namespace
,
project
)
visit
namespace_project_path
(
project
.
namespace
,
project
)
page
.
within
'.search'
do
page
.
within
'.search'
do
fill_in
'search'
,
with:
'
def
'
fill_in
'search'
,
with:
'
application.js
'
click_button
'Go'
click_button
'Go'
end
end
click_link
"Code"
click_link
"Code"
expect
(
page
).
to
have_selector
(
'.file-content .code'
)
expect
(
page
).
to
have_selector
(
'.file-content .code'
)
expect
(
page
).
to
have_selector
(
"span.line[lang='javascript']"
)
end
end
end
end
...
...
spec/lib/gitlab/project_search_results_spec.rb
View file @
7f32ad70
...
@@ -41,8 +41,10 @@ describe Gitlab::ProjectSearchResults, lib: true do
...
@@ -41,8 +41,10 @@ describe Gitlab::ProjectSearchResults, lib: true do
subject
{
described_class
.
parse_search_result
(
search_result
)
}
subject
{
described_class
.
parse_search_result
(
search_result
)
}
it
"returns a valid OpenStruct object"
do
it
"returns a valid FoundBlob"
do
is_expected
.
to
be_an
OpenStruct
is_expected
.
to
be_an
Gitlab
::
SearchResults
::
FoundBlob
expect
(
subject
.
id
).
to
be_nil
expect
(
subject
.
path
).
to
eq
(
'CHANGELOG'
)
expect
(
subject
.
filename
).
to
eq
(
'CHANGELOG'
)
expect
(
subject
.
filename
).
to
eq
(
'CHANGELOG'
)
expect
(
subject
.
basename
).
to
eq
(
'CHANGELOG'
)
expect
(
subject
.
basename
).
to
eq
(
'CHANGELOG'
)
expect
(
subject
.
ref
).
to
eq
(
'master'
)
expect
(
subject
.
ref
).
to
eq
(
'master'
)
...
@@ -53,6 +55,7 @@ describe Gitlab::ProjectSearchResults, lib: true do
...
@@ -53,6 +55,7 @@ describe Gitlab::ProjectSearchResults, lib: true do
context
"when filename has extension"
do
context
"when filename has extension"
do
let
(
:search_result
)
{
"master:CONTRIBUTE.md:5:- [Contribute to GitLab](#contribute-to-gitlab)
\n
"
}
let
(
:search_result
)
{
"master:CONTRIBUTE.md:5:- [Contribute to GitLab](#contribute-to-gitlab)
\n
"
}
it
{
expect
(
subject
.
path
).
to
eq
(
'CONTRIBUTE.md'
)
}
it
{
expect
(
subject
.
filename
).
to
eq
(
'CONTRIBUTE.md'
)
}
it
{
expect
(
subject
.
filename
).
to
eq
(
'CONTRIBUTE.md'
)
}
it
{
expect
(
subject
.
basename
).
to
eq
(
'CONTRIBUTE'
)
}
it
{
expect
(
subject
.
basename
).
to
eq
(
'CONTRIBUTE'
)
}
end
end
...
@@ -60,6 +63,7 @@ describe Gitlab::ProjectSearchResults, lib: true do
...
@@ -60,6 +63,7 @@ describe Gitlab::ProjectSearchResults, lib: true do
context
"when file under directory"
do
context
"when file under directory"
do
let
(
:search_result
)
{
"master:a/b/c.md:5:a b c
\n
"
}
let
(
:search_result
)
{
"master:a/b/c.md:5:a b c
\n
"
}
it
{
expect
(
subject
.
path
).
to
eq
(
'a/b/c.md'
)
}
it
{
expect
(
subject
.
filename
).
to
eq
(
'a/b/c.md'
)
}
it
{
expect
(
subject
.
filename
).
to
eq
(
'a/b/c.md'
)
}
it
{
expect
(
subject
.
basename
).
to
eq
(
'a/b/c'
)
}
it
{
expect
(
subject
.
basename
).
to
eq
(
'a/b/c'
)
}
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