Commit 22613480 authored by Dmitry Gruzd's avatar Dmitry Gruzd

Merge branch 'change-abuse-logging-format' into 'master'

Change format of abuse detection logging

See merge request gitlab-org/gitlab!76474
parents f7eb9240 596c5cd4
......@@ -80,7 +80,7 @@ class SearchService
def abuse_messages
return [] unless params.abusive?
params.abuse_detection.errors.messages
params.abuse_detection.errors.full_messages
end
def valid_request?
......
......@@ -569,6 +569,27 @@ RSpec.describe SearchService do
end
end
describe '#abuse_messages' do
let(:scope) { 'issues' }
let(:search) { 'foobar' }
let(:params) { instance_double(Gitlab::Search::Params) }
before do
allow(Gitlab::Search::Params).to receive(:new).and_return(params)
end
it 'returns an empty array when not abusive' do
allow(params).to receive(:abusive?).and_return false
expect(subject.abuse_messages).to match_array([])
end
it 'calls on abuse_detection.errors.full_messages when abusive' do
allow(params).to receive(:abusive?).and_return true
expect(params).to receive_message_chain(:abuse_detection, :errors, :full_messages)
subject.abuse_messages
end
end
describe 'abusive search handling' do
subject { described_class.new(user, raw_params) }
......
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