Commit a84d260e authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch...

Merge branch '217158-nomethoderror-undefined-method-without_count-for-kaminari-paginatablearray' into 'master'

Don't override allowed_scopes for non-ES searches

See merge request gitlab-org/gitlab!31508
parents 6bb5e629 bb4687e4
......@@ -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