Commit bcd369a6 authored by Dmitry Gruzd's avatar Dmitry Gruzd

Merge branch '326470-global-search-lock-the-order-of-the-scope-tabs' into 'master'

Search: Always show scope tabs regardless of tab selected

See merge request gitlab-org/gitlab!59777
parents 03f9cc03 2861c45f
...@@ -23,5 +23,9 @@ module EE ...@@ -23,5 +23,9 @@ module EE
def show_epics? def show_epics?
search_service.allowed_scopes.include?('epics') search_service.allowed_scopes.include?('epics')
end end
def show_elasticsearch_tabs?
::Gitlab::CurrentSettings.search_using_elasticsearch?(scope: search_service.elasticsearchable_scope)
end
end end
end end
- if search_service.use_elasticsearch? - if search_service.show_elasticsearch_tabs?
= search_filter_link 'notes', _("Comments") = search_filter_link 'notes', _("Comments")
= search_filter_link 'blobs', _("Code"), data: { qa_selector: 'code_tab' } = search_filter_link 'blobs', _("Code"), data: { qa_selector: 'code_tab' }
= search_filter_link 'commits', _("Commits") = search_filter_link 'commits', _("Commits")
......
---
title: Lock the order of the Search scope tabs
merge_request: 59777
author:
type: fixed
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe SearchController do RSpec.describe SearchController, :elastic do
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
before do before do
...@@ -10,7 +10,7 @@ RSpec.describe SearchController do ...@@ -10,7 +10,7 @@ RSpec.describe SearchController do
end end
describe 'GET #show' do describe 'GET #show' do
context 'unique users tracking', :elastic do context 'unique users tracking' do
before do before do
stub_ee_application_setting(elasticsearch_search: true, elasticsearch_indexing: true) stub_ee_application_setting(elasticsearch_search: true, elasticsearch_indexing: true)
allow(Gitlab::UsageDataCounters::HLLRedisCounter).to receive(:track_event) allow(Gitlab::UsageDataCounters::HLLRedisCounter).to receive(:track_event)
...@@ -70,5 +70,61 @@ RSpec.describe SearchController do ...@@ -70,5 +70,61 @@ RSpec.describe SearchController do
end end
end end
end end
shared_examples 'renders the elasticsearch tabs if elasticsearch is enabled' do
using RSpec::Parameterized::TableSyntax
render_views
subject { get :show, params: request_params, format: :html }
where(:scope) { %w[projects issues merge_requests milestones epics notes blobs commits wiki_blobs users] }
with_them do
context 'when elasticsearch is enabled' do
before do
stub_ee_application_setting(elasticsearch_search: true, elasticsearch_indexing: true)
end
it 'shows the elasticsearch tabs' do
subject
expect(response.body).to have_link('Code')
expect(response.body).to have_link('Wiki')
expect(response.body).to have_link('Comments')
expect(response.body).to have_link('Commits')
end
end
context 'when elasticsearch is disabled' do
before do
stub_ee_application_setting(elasticsearch_search: false, elasticsearch_indexing: false)
end
it 'does not show the elasticsearch tabs' do
subject
expect(response.body).not_to have_link('Code')
expect(response.body).not_to have_link('Wiki')
expect(response.body).not_to have_link('Comments')
expect(response.body).not_to have_link('Commits')
end
end
end
end
context 'global search' do
let(:request_params) { { scope: scope, search: 'term' } }
it_behaves_like 'renders the elasticsearch tabs if elasticsearch is enabled'
end
context 'group search' do
let_it_be(:group) { create(:group) }
let(:request_params) { { group_id: group.id, scope: scope, search: 'term' } }
it_behaves_like 'renders the elasticsearch tabs if elasticsearch is enabled'
end
end end
end end
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