Commit 1a424a9b authored by Valery Sizov's avatar Valery Sizov

Explicitly test that guest is able to search through the wiki

parent 7487d06c
...@@ -34,6 +34,12 @@ module SearchHelper ...@@ -34,6 +34,12 @@ module SearchHelper
Gitlab::ProjectSearchResults.parse_search_result(result) Gitlab::ProjectSearchResults.parse_search_result(result)
end end
def show_notes_tab?
[:read_merge_request, :download_code, :read_issue, :read_project_snippet].all? do |ability|
can?(current_user, :read_merge_request, @project)
end
end
private private
# Autocomplete results for various settings pages # Autocomplete results for various settings pages
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
Milestones Milestones
%span.badge %span.badge
= @search_results.milestones_count = @search_results.milestones_count
- if can?(current_user, :read_merge_request, @project) || can?(current_user, :read_issue, @project) - if show_notes_tab?
%li{ class: active_when(@scope == 'notes') } %li{ class: active_when(@scope == 'notes') }
= link_to search_filter_path(scope: 'notes') do = link_to search_filter_path(scope: 'notes') do
Comments Comments
......
...@@ -123,8 +123,8 @@ describe Gitlab::ProjectSearchResults, lib: true do ...@@ -123,8 +123,8 @@ describe Gitlab::ProjectSearchResults, lib: true do
context 'when wiki is internal' do context 'when wiki is internal' do
let(:project) { create(:project, :public, :wiki_private) } let(:project) { create(:project, :public, :wiki_private) }
it 'finds wiki blobs for members' do it 'finds wiki blobs for guest' do
project.add_reporter(user) project.add_guest(user)
is_expected.not_to be_empty is_expected.not_to be_empty
end end
......
...@@ -29,7 +29,7 @@ describe SearchService, services: true do ...@@ -29,7 +29,7 @@ describe SearchService, services: true do
it 'returns the project for guests' do it 'returns the project for guests' do
search_project = create :empty_project search_project = create :empty_project
search_project.team << [user, :guest] search_project.add_guest(user)
project = SearchService.new(user, project_id: search_project.id).project project = SearchService.new(user, project_id: search_project.id).project
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment