Commit bb4687e4 authored by Alishan Ladhani's avatar Alishan Ladhani

Make elasticsearch check more thorough

So that allowed scopes are not overridden when
limit_indexing is on
parent bf44d054
......@@ -42,9 +42,11 @@ module EE
override :allowed_scopes
def allowed_scopes
return super unless use_elasticsearch?
strong_memoize(:ee_allowed_scopes) do
super.tap do |ce_scopes|
ce_scopes.concat(%w[notes wiki_blobs blobs commits]) if ::Gitlab::CurrentSettings.elasticsearch_search?
ce_scopes.concat(%w[notes wiki_blobs blobs commits])
end
end
end
......
---
title: Fix 500 errors caused by globally searching for scopes which cannot be used without
Elasticsearch
merge_request: 31508
author:
type: fixed
......@@ -169,4 +169,22 @@ describe Search::GlobalService do
end
end
end
describe '#allowed_scopes' do
context 'when ES is used' do
it 'includes ES-specific scopes' do
expect(described_class.new(user, {}).allowed_scopes).to include('commits')
end
end
context 'when ES is not used' do
before do
stub_ee_application_setting(elasticsearch_limit_indexing: true)
end
it 'does not include ES-specific scopes' do
expect(described_class.new(user, {}).allowed_scopes).not_to include('commits')
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