diff options
author | Valery Sizov <valery@gitlab.com> | 2017-05-23 13:40:18 +0300 |
---|---|---|
committer | Valery Sizov <valery@gitlab.com> | 2017-05-29 16:20:25 +0300 |
commit | 1a424a9bc9cf1fbabd70ac2384978ae94674e6d7 (patch) | |
tree | 99d756dc5965119793e95eaecc51b33bb0451efc | |
parent | 7487d06c4ba7f186fddc11aa39ab66e8cb4ccc14 (diff) | |
download | gitlab-ce-1a424a9bc9cf1fbabd70ac2384978ae94674e6d7.tar.gz |
Explicitly test that guest is able to search through the wiki
-rw-r--r-- | app/helpers/search_helper.rb | 6 | ||||
-rw-r--r-- | app/views/search/_category.html.haml | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/project_search_results_spec.rb | 4 | ||||
-rw-r--r-- | spec/services/search_service_spec.rb | 2 |
4 files changed, 10 insertions, 4 deletions
diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index 9c46035057f..9021525784d 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -33,6 +33,12 @@ module SearchHelper def parse_search_result(result) Gitlab::ProjectSearchResults.parse_search_result(result) 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 diff --git a/app/views/search/_category.html.haml b/app/views/search/_category.html.haml index 7ec4aa9998f..df73fb173a8 100644 --- a/app/views/search/_category.html.haml +++ b/app/views/search/_category.html.haml @@ -27,7 +27,7 @@ Milestones %span.badge = @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') } = link_to search_filter_path(scope: 'notes') do Comments diff --git a/spec/lib/gitlab/project_search_results_spec.rb b/spec/lib/gitlab/project_search_results_spec.rb index 1b8690ba613..3d22784909d 100644 --- a/spec/lib/gitlab/project_search_results_spec.rb +++ b/spec/lib/gitlab/project_search_results_spec.rb @@ -123,8 +123,8 @@ describe Gitlab::ProjectSearchResults, lib: true do context 'when wiki is internal' do let(:project) { create(:project, :public, :wiki_private) } - it 'finds wiki blobs for members' do - project.add_reporter(user) + it 'finds wiki blobs for guest' do + project.add_guest(user) is_expected.not_to be_empty end diff --git a/spec/services/search_service_spec.rb b/spec/services/search_service_spec.rb index 694124a8be3..5cf989105d0 100644 --- a/spec/services/search_service_spec.rb +++ b/spec/services/search_service_spec.rb @@ -29,7 +29,7 @@ describe SearchService, services: true do it 'returns the project for guests' do 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 |