Commit 19b7a490 authored by Sean Arnold's avatar Sean Arnold

Ignore blank searches

parent d6528bb4
...@@ -35,7 +35,7 @@ module AlertManagement ...@@ -35,7 +35,7 @@ module AlertManagement
end end
def by_search(collection) def by_search(collection)
params[:search] ? collection.search(params[:search]) : collection params[:search].present? ? collection.search(params[:search]) : collection
end end
def sort(collection) def sort(collection)
......
...@@ -227,7 +227,6 @@ describe AlertManagement::AlertsFinder, '#execute' do ...@@ -227,7 +227,6 @@ describe AlertManagement::AlertsFinder, '#execute' do
let_it_be(:alert) do let_it_be(:alert) do
create(:alert_management_alert, create(:alert_management_alert,
:with_fingerprint, :with_fingerprint,
project: project,
title: 'Title', title: 'Title',
description: 'Desc', description: 'Desc',
service: 'Service', service: 'Service',
...@@ -235,6 +234,12 @@ describe AlertManagement::AlertsFinder, '#execute' do ...@@ -235,6 +234,12 @@ describe AlertManagement::AlertsFinder, '#execute' do
) )
end end
before do
alert.project.add_developer(current_user)
end
subject { described_class.new(current_user, alert.project, params).execute }
context 'searching title' do context 'searching title' do
let(:params) { { search: alert.title } } let(:params) { { search: alert.title } }
...@@ -264,6 +269,12 @@ describe AlertManagement::AlertsFinder, '#execute' do ...@@ -264,6 +269,12 @@ describe AlertManagement::AlertsFinder, '#execute' do
it { is_expected.to be_empty } it { is_expected.to be_empty }
end end
context 'empty search' do
let(:params) { { search: ' ' } }
it { is_expected.to match_array([alert]) }
end
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