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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
893b1eb1
Commit
893b1eb1
authored
May 22, 2017
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: Wiki is not searchable with Guest permissions
parent
72119e7f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
36 deletions
+52
-36
app/services/search_service.rb
app/services/search_service.rb
+1
-1
app/views/search/_category.html.haml
app/views/search/_category.html.haml
+42
-35
spec/services/search_service_spec.rb
spec/services/search_service_spec.rb
+9
-0
No files found.
app/services/search_service.rb
View file @
893b1eb1
...
...
@@ -12,7 +12,7 @@ class SearchService
@project
=
if
params
[
:project_id
].
present?
the_project
=
Project
.
find_by
(
id:
params
[
:project_id
])
can?
(
current_user
,
:
download_code
,
the_project
)
?
the_project
:
nil
can?
(
current_user
,
:
read_project
,
the_project
)
?
the_project
:
nil
else
nil
end
...
...
app/views/search/_category.html.haml
View file @
893b1eb1
...
...
@@ -3,41 +3,48 @@
.fade-right
=
icon
(
'angle-right'
)
%ul
.nav-links.search-filter.scrolling-tabs
-
if
@project
%li
{
class:
active_when
(
@scope
==
'blobs'
)
}
=
link_to
search_filter_path
(
scope:
'blobs'
)
do
Code
%span
.badge
=
@search_results
.
blobs_count
%li
{
class:
active_when
(
@scope
==
'issues'
)
}
=
link_to
search_filter_path
(
scope:
'issues'
)
do
Issues
%span
.badge
=
@search_results
.
issues_count
%li
{
class:
active_when
(
@scope
==
'merge_requests'
)
}
=
link_to
search_filter_path
(
scope:
'merge_requests'
)
do
Merge requests
%span
.badge
=
@search_results
.
merge_requests_count
%li
{
class:
active_when
(
@scope
==
'milestones'
)
}
=
link_to
search_filter_path
(
scope:
'milestones'
)
do
Milestones
%span
.badge
=
@search_results
.
milestones_count
%li
{
class:
active_when
(
@scope
==
'notes'
)
}
=
link_to
search_filter_path
(
scope:
'notes'
)
do
Comments
%span
.badge
=
@search_results
.
notes_count
%li
{
class:
active_when
(
@scope
==
'wiki_blobs'
)
}
=
link_to
search_filter_path
(
scope:
'wiki_blobs'
)
do
Wiki
%span
.badge
=
@search_results
.
wiki_blobs_count
%li
{
class:
active_when
(
@scope
==
'commits'
)
}
=
link_to
search_filter_path
(
scope:
'commits'
)
do
Commits
%span
.badge
=
@search_results
.
commits_count
-
if
can?
(
current_user
,
:download_code
,
@project
)
%li
{
class:
active_when
(
@scope
==
'blobs'
)
}
=
link_to
search_filter_path
(
scope:
'blobs'
)
do
Code
%span
.badge
=
@search_results
.
blobs_count
-
if
can?
(
current_user
,
:read_issue
,
@project
)
%li
{
class:
active_when
(
@scope
==
'issues'
)
}
=
link_to
search_filter_path
(
scope:
'issues'
)
do
Issues
%span
.badge
=
@search_results
.
issues_count
-
if
can?
(
current_user
,
:read_merge_request
,
@project
)
%li
{
class:
active_when
(
@scope
==
'merge_requests'
)
}
=
link_to
search_filter_path
(
scope:
'merge_requests'
)
do
Merge requests
%span
.badge
=
@search_results
.
merge_requests_count
-
if
can?
(
current_user
,
:read_milestone
,
@project
)
%li
{
class:
active_when
(
@scope
==
'milestones'
)
}
=
link_to
search_filter_path
(
scope:
'milestones'
)
do
Milestones
%span
.badge
=
@search_results
.
milestones_count
-
if
can?
(
current_user
,
:read_merge_request
,
@project
)
||
can?
(
current_user
,
:read_issue
,
@project
)
%li
{
class:
active_when
(
@scope
==
'notes'
)
}
=
link_to
search_filter_path
(
scope:
'notes'
)
do
Comments
%span
.badge
=
@search_results
.
notes_count
-
if
can?
(
current_user
,
:read_wiki
,
@project
)
%li
{
class:
active_when
(
@scope
==
'wiki_blobs'
)
}
=
link_to
search_filter_path
(
scope:
'wiki_blobs'
)
do
Wiki
%span
.badge
=
@search_results
.
wiki_blobs_count
-
if
can?
(
current_user
,
:download_code
,
@project
)
%li
{
class:
active_when
(
@scope
==
'commits'
)
}
=
link_to
search_filter_path
(
scope:
'commits'
)
do
Commits
%span
.badge
=
@search_results
.
commits_count
-
elsif
@show_snippets
%li
{
class:
active_when
(
@scope
==
'snippet_blobs'
)
}
...
...
spec/services/search_service_spec.rb
View file @
893b1eb1
...
...
@@ -26,6 +26,15 @@ describe SearchService, services: true do
expect
(
project
).
to
eq
accessible_project
end
it
'returns the project for guests'
do
search_project
=
create
:empty_project
search_project
.
team
<<
[
user
,
:guest
]
project
=
SearchService
.
new
(
user
,
project_id:
search_project
.
id
).
project
expect
(
project
).
to
eq
search_project
end
end
context
'when the project is not accessible'
do
...
...
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