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
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
ec19a960
Commit
ec19a960
authored
Jul 12, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for repository search files
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
9ab12e09
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
1 deletion
+25
-1
app/models/repository.rb
app/models/repository.rb
+1
-1
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+24
-0
No files found.
app/models/repository.rb
View file @
ec19a960
...
@@ -442,7 +442,7 @@ class Repository
...
@@ -442,7 +442,7 @@ class Repository
filename
=
nil
filename
=
nil
startline
=
0
startline
=
0
lines
=
result
.
l
strip
.
l
ines
lines
=
result
.
lines
lines
.
each_with_index
do
|
line
,
index
|
lines
.
each_with_index
do
|
line
,
index
|
if
line
=~
/^.*:.*:\d+:/
if
line
=~
/^.*:.*:\d+:/
ref
,
filename
,
startline
=
line
.
split
(
':'
)
ref
,
filename
,
startline
=
line
.
split
(
':'
)
...
...
spec/models/repository_spec.rb
View file @
ec19a960
...
@@ -47,4 +47,28 @@ describe Repository do
...
@@ -47,4 +47,28 @@ describe Repository do
it
{
is_expected
.
to
be_falsey
}
it
{
is_expected
.
to
be_falsey
}
end
end
end
end
describe
"search_files"
do
let
(
:results
)
{
repository
.
search_files
(
'feature'
,
'master'
)
}
subject
{
results
}
it
{
is_expected
.
to
be_an
Array
}
describe
'result'
do
subject
{
results
.
first
}
it
{
is_expected
.
to
be_an
String
}
it
{
expect
(
subject
.
lines
[
2
]).
to
eq
(
"master:CHANGELOG:188: - Feature: Replace teams with group membership
\n
"
)
}
end
describe
'parsing result'
do
subject
{
repository
.
parse_search_result
(
results
.
first
)
}
it
{
is_expected
.
to
be_an
OpenStruct
}
it
{
expect
(
subject
.
filename
).
to
eq
(
'CHANGELOG'
)
}
it
{
expect
(
subject
.
ref
).
to
eq
(
'master'
)
}
it
{
expect
(
subject
.
startline
).
to
eq
(
186
)
}
it
{
expect
(
subject
.
data
.
lines
[
2
]).
to
eq
(
" - Feature: Replace teams with group membership
\n
"
)
}
end
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