Commit d6528bb4 authored by Sean Arnold's avatar Sean Arnold

Refactor specs to reduce complexity

parent f3697d79
......@@ -224,32 +224,43 @@ describe AlertManagement::AlertsFinder, '#execute' do
end
context 'search query given' do
let_it_be(:alert) do
create(:alert_management_alert,
:with_fingerprint,
project: project,
title: 'Title',
description: 'Desc',
service: 'Service',
monitoring_tool: 'Monitor'
)
end
context 'searching title' do
let(:params) { { search: alert_1.title } }
let(:params) { { search: alert.title } }
it { is_expected.to match_array([alert_1]) }
it { is_expected.to match_array([alert]) }
end
context 'searching description' do
let(:params) { { search: alert_1.description } }
let(:params) { { search: alert.description } }
it { is_expected.to match_array([alert_1]) }
it { is_expected.to match_array([alert]) }
end
context 'searching service' do
let(:params) { { search: alert_1.service } }
let(:params) { { search: alert.service } }
it { is_expected.to match_array([alert_1]) }
it { is_expected.to match_array([alert]) }
end
context 'searching monitoring tool' do
let(:params) { { search: alert_1.monitoring_tool } }
let(:params) { { search: alert.monitoring_tool } }
it { is_expected.to match_array([alert_1]) }
it { is_expected.to match_array([alert]) }
end
context 'searching something else' do
let(:params) { { search: alert_1.fingerprint } }
let(:params) { { search: alert.fingerprint } }
it { is_expected.to be_empty }
end
......
......@@ -163,37 +163,43 @@ describe AlertManagement::Alert do
end
describe '.search' do
let(:query) { 'rspec' }
let(:attribute_data) { 'RSPEC data' }
let_it_be(:alert) do
create(:alert_management_alert,
title: 'Title',
description: 'Desc',
service: 'Service',
monitoring_tool: 'Monitor'
)
end
subject { AlertManagement::Alert.search(query) }
context 'does not contain search string' do
let!(:alert) { create(:alert_management_alert) }
let(:query) { 'something else' }
it { is_expected.to be_empty }
end
context 'title includes query' do
let!(:alert) { create(:alert_management_alert, title: attribute_data) }
let(:query) { alert.title.upcase }
it { is_expected.to contain_exactly(alert) }
end
context 'description includes query' do
let!(:alert) { create(:alert_management_alert, description: attribute_data) }
let(:query) { alert.description.upcase }
it { is_expected.to contain_exactly(alert) }
end
context 'service includes query' do
let!(:alert) { create(:alert_management_alert, service: attribute_data) }
let(:query) { alert.service.upcase }
it { is_expected.to contain_exactly(alert) }
end
context 'monitoring tool includes query' do
let!(:alert) { create(:alert_management_alert, monitoring_tool: attribute_data) }
let(:query) { alert.monitoring_tool.upcase }
it { is_expected.to contain_exactly(alert) }
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