Commit 95011e7a authored by Mark Chao's avatar Mark Chao

Merge branch '247636-fix-logging-search-scope' into 'master'

Search: Log search.scope for the default scope

See merge request gitlab-org/gitlab!54684
parents c4eb06e4 caf30864
...@@ -125,7 +125,7 @@ class SearchController < ApplicationController ...@@ -125,7 +125,7 @@ class SearchController < ApplicationController
payload[:metadata] ||= {} payload[:metadata] ||= {}
payload[:metadata]['meta.search.group_id'] = params[:group_id] payload[:metadata]['meta.search.group_id'] = params[:group_id]
payload[:metadata]['meta.search.project_id'] = params[:project_id] payload[:metadata]['meta.search.project_id'] = params[:project_id]
payload[:metadata]['meta.search.scope'] = params[:scope] payload[:metadata]['meta.search.scope'] = params[:scope] || @scope
payload[:metadata]['meta.search.filters.confidential'] = params[:confidential] payload[:metadata]['meta.search.filters.confidential'] = params[:confidential]
payload[:metadata]['meta.search.filters.state'] = params[:state] payload[:metadata]['meta.search.filters.state'] = params[:state]
payload[:metadata]['meta.search.force_search_results'] = params[:force_search_results] payload[:metadata]['meta.search.force_search_results'] = params[:force_search_results]
......
---
title: 'Search: Log search.scope for the default scope'
merge_request: 54684
author:
type: fixed
...@@ -261,23 +261,29 @@ RSpec.describe SearchController do ...@@ -261,23 +261,29 @@ RSpec.describe SearchController do
describe '#append_info_to_payload' do describe '#append_info_to_payload' do
it 'appends search metadata for logging' do it 'appends search metadata for logging' do
last_payload = nil expect(controller).to receive(:append_info_to_payload).and_wrap_original do |method, payload|
original_append_info_to_payload = controller.method(:append_info_to_payload) method.call(payload)
expect(controller).to receive(:append_info_to_payload) do |payload| expect(payload[:metadata]['meta.search.group_id']).to eq('123')
original_append_info_to_payload.call(payload) expect(payload[:metadata]['meta.search.project_id']).to eq('456')
last_payload = payload expect(payload[:metadata]).not_to have_key('meta.search.search')
expect(payload[:metadata]['meta.search.scope']).to eq('issues')
expect(payload[:metadata]['meta.search.force_search_results']).to eq('true')
expect(payload[:metadata]['meta.search.filters.confidential']).to eq('true')
expect(payload[:metadata]['meta.search.filters.state']).to eq('true')
end end
get :show, params: { scope: 'issues', search: 'hello world', group_id: '123', project_id: '456', confidential: true, state: true, force_search_results: true } get :show, params: { scope: 'issues', search: 'hello world', group_id: '123', project_id: '456', confidential: true, state: true, force_search_results: true }
end
it 'appends the default scope in meta.search.scope' do
expect(controller).to receive(:append_info_to_payload).and_wrap_original do |method, payload|
method.call(payload)
expect(payload[:metadata]['meta.search.scope']).to eq('projects')
end
expect(last_payload[:metadata]['meta.search.group_id']).to eq('123') get :show, params: { search: 'hello world', group_id: '123', project_id: '456' }
expect(last_payload[:metadata]['meta.search.project_id']).to eq('456')
expect(last_payload[:metadata]).not_to have_key('meta.search.search')
expect(last_payload[:metadata]['meta.search.scope']).to eq('issues')
expect(last_payload[:metadata]['meta.search.force_search_results']).to eq('true')
expect(last_payload[:metadata]['meta.search.filters.confidential']).to eq('true')
expect(last_payload[:metadata]['meta.search.filters.state']).to eq('true')
end 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