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
ffbbccb7
Commit
ffbbccb7
authored
Jan 18, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix search autocomplete
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
073a2698
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
19 deletions
+8
-19
spec/helpers/search_helper_spec.rb
spec/helpers/search_helper_spec.rb
+8
-19
No files found.
spec/helpers/search_helper_spec.rb
View file @
ffbbccb7
...
...
@@ -13,52 +13,41 @@ describe SearchHelper do
end
it
"it returns nil"
do
search_autocomplete_
source
.
should
be_nil
search_autocomplete_
opts
(
"q"
)
.
should
be_nil
end
end
context
"with a user"
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:result
)
{
JSON
.
parse
(
search_autocomplete_source
)
}
before
do
allow
(
self
).
to
receive
(
:current_user
).
and_return
(
user
)
end
it
"includes Help sections"
do
result
.
select
{
|
h
|
h
[
'label'
]
=~
/^help:/
}.
length
.
should
==
9
search_autocomplete_opts
(
"hel"
).
size
.
should
==
9
end
it
"includes default sections"
do
result
.
count
{
|
h
|
h
[
'label'
]
=~
/^(My|Admin)\s/
}.
should
==
4
search_autocomplete_opts
(
"adm"
).
size
.
should
==
1
end
it
"includes the user's groups"
do
create
(
:group
).
add_owner
(
user
)
result
.
count
{
|
h
|
h
[
'label'
]
=~
/^group:/
}
.
should
==
1
search_autocomplete_opts
(
"gro"
).
size
.
should
==
1
end
it
"includes the user's projects"
do
create
(
:project
,
namespace:
create
(
:namespace
,
owner:
user
))
result
.
count
{
|
h
|
h
[
'label'
]
=~
/^project:/
}
.
should
==
1
project
=
create
(
:project
,
namespace:
create
(
:namespace
,
owner:
user
))
search_autocomplete_opts
(
project
.
name
).
size
.
should
==
1
end
context
"with a current project"
do
before
{
@project
=
create
(
:project_with_code
)
}
it
"includes project-specific sections"
do
result
.
count
{
|
h
|
h
[
'label'
]
=~
/^
#{
@project
.
name_with_namespace
}
- /
}.
should
==
11
end
it
"uses @ref in urls if defined"
do
@ref
=
"foo_bar"
result
.
count
{
|
h
|
h
[
'url'
]
==
project_tree_path
(
@project
,
@ref
)
}.
should
==
1
end
end
context
"with no current project"
do
it
"does not include project-specific sections"
do
result
.
count
{
|
h
|
h
[
'label'
]
=~
/Files$/
}.
should
==
0
search_autocomplete_opts
(
"Files"
).
size
.
should
==
1
search_autocomplete_opts
(
"Commits"
).
size
.
should
==
1
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