summaryrefslogtreecommitdiff
path: root/spec/requests/api/search_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/requests/api/search_spec.rb')
-rw-r--r--spec/requests/api/search_spec.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/requests/api/search_spec.rb b/spec/requests/api/search_spec.rb
index 430d3b7d187..035f53db12e 100644
--- a/spec/requests/api/search_spec.rb
+++ b/spec/requests/api/search_spec.rb
@@ -377,6 +377,26 @@ RSpec.describe API::Search, feature_category: :global_search do
end
end
+ context 'global search is disabled for the given scope' do
+ it 'returns forbidden response' do
+ allow_next_instance_of(SearchService) do |instance|
+ allow(instance).to receive(:global_search_enabled_for_scope?).and_return false
+ end
+ get api(endpoint, user), params: { search: 'awesome', scope: 'issues' }
+ expect(response).to have_gitlab_http_status(:forbidden)
+ end
+ end
+
+ context 'global search is enabled for the given scope' do
+ it 'returns forbidden response' do
+ allow_next_instance_of(SearchService) do |instance|
+ allow(instance).to receive(:global_search_enabled_for_scope?).and_return true
+ end
+ get api(endpoint, user), params: { search: 'awesome', scope: 'issues' }
+ expect(response).to have_gitlab_http_status(:ok)
+ end
+ end
+
it 'increments the custom search sli error rate with error false if no error occurred' do
expect(Gitlab::Metrics::GlobalSearchSlis).to receive(:record_error_rate).with(
error: false,