Commit 40600094 authored by Vitali Tatarintev's avatar Vitali Tatarintev Committed by Peter Leitzen

Rename variables to increase tests readability

parent 425afac6
...@@ -7,8 +7,8 @@ describe 'getting Alert Management Alerts' do ...@@ -7,8 +7,8 @@ describe 'getting Alert Management Alerts' do
let_it_be(:payload) { { 'custom' => { 'alert' => 'payload' } } } let_it_be(:payload) { { 'custom' => { 'alert' => 'payload' } } }
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let_it_be(:current_user) { create(:user) } let_it_be(:current_user) { create(:user) }
let_it_be(:alert_1) { create(:alert_management_alert, :all_fields, :resolved, project: project, issue: nil, severity: :low) } let_it_be(:resolved_alert) { create(:alert_management_alert, :all_fields, :resolved, project: project, issue: nil, severity: :low) }
let_it_be(:alert_2) { create(:alert_management_alert, :all_fields, project: project, severity: :critical, payload: payload) } let_it_be(:triggered_alert) { create(:alert_management_alert, :all_fields, project: project, severity: :critical, payload: payload) }
let_it_be(:other_project_alert) { create(:alert_management_alert, :all_fields) } let_it_be(:other_project_alert) { create(:alert_management_alert, :all_fields) }
let(:params) { {} } let(:params) { {} }
...@@ -58,38 +58,38 @@ describe 'getting Alert Management Alerts' do ...@@ -58,38 +58,38 @@ describe 'getting Alert Management Alerts' do
it 'returns the correct properties of the alerts' do it 'returns the correct properties of the alerts' do
expect(first_alert).to include( expect(first_alert).to include(
'iid' => alert_2.iid.to_s, 'iid' => triggered_alert.iid.to_s,
'issueIid' => alert_2.issue_iid.to_s, 'issueIid' => triggered_alert.issue_iid.to_s,
'title' => alert_2.title, 'title' => triggered_alert.title,
'description' => alert_2.description, 'description' => triggered_alert.description,
'severity' => alert_2.severity.upcase, 'severity' => triggered_alert.severity.upcase,
'status' => 'TRIGGERED', 'status' => 'TRIGGERED',
'monitoringTool' => alert_2.monitoring_tool, 'monitoringTool' => triggered_alert.monitoring_tool,
'service' => alert_2.service, 'service' => triggered_alert.service,
'hosts' => alert_2.hosts, 'hosts' => triggered_alert.hosts,
'eventCount' => alert_2.events, 'eventCount' => triggered_alert.events,
'startedAt' => alert_2.started_at.strftime('%Y-%m-%dT%H:%M:%SZ'), 'startedAt' => triggered_alert.started_at.strftime('%Y-%m-%dT%H:%M:%SZ'),
'endedAt' => nil, 'endedAt' => nil,
'details' => { 'custom.alert' => 'payload' }, 'details' => { 'custom.alert' => 'payload' },
'createdAt' => alert_2.created_at.strftime('%Y-%m-%dT%H:%M:%SZ'), 'createdAt' => triggered_alert.created_at.strftime('%Y-%m-%dT%H:%M:%SZ'),
'updatedAt' => alert_2.updated_at.strftime('%Y-%m-%dT%H:%M:%SZ') 'updatedAt' => triggered_alert.updated_at.strftime('%Y-%m-%dT%H:%M:%SZ')
) )
expect(second_alert).to include( expect(second_alert).to include(
'iid' => alert_1.iid.to_s, 'iid' => resolved_alert.iid.to_s,
'issueIid' => nil, 'issueIid' => nil,
'status' => 'RESOLVED', 'status' => 'RESOLVED',
'endedAt' => alert_1.ended_at.strftime('%Y-%m-%dT%H:%M:%SZ') 'endedAt' => resolved_alert.ended_at.strftime('%Y-%m-%dT%H:%M:%SZ')
) )
end end
context 'with iid given' do context 'with iid given' do
let(:params) { { iid: alert_1.iid.to_s } } let(:params) { { iid: resolved_alert.iid.to_s } }
it_behaves_like 'a working graphql query' it_behaves_like 'a working graphql query'
it { expect(alerts.size).to eq(1) } it { expect(alerts.size).to eq(1) }
it { expect(first_alert['iid']).to eq(alert_1.iid.to_s) } it { expect(first_alert['iid']).to eq(resolved_alert.iid.to_s) }
end end
context 'sorting data given' do context 'sorting data given' do
...@@ -99,25 +99,25 @@ describe 'getting Alert Management Alerts' do ...@@ -99,25 +99,25 @@ describe 'getting Alert Management Alerts' do
it_behaves_like 'a working graphql query' it_behaves_like 'a working graphql query'
it 'sorts in the correct order' do it 'sorts in the correct order' do
expect(iids).to eq [alert_1.iid.to_s, alert_2.iid.to_s] expect(iids).to eq [resolved_alert.iid.to_s, triggered_alert.iid.to_s]
end end
context 'ascending order' do context 'ascending order' do
let(:params) { 'sort: SEVERITY_ASC' } let(:params) { 'sort: SEVERITY_ASC' }
it 'sorts in the correct order' do it 'sorts in the correct order' do
expect(iids).to eq [alert_2.iid.to_s, alert_1.iid.to_s] expect(iids).to eq [triggered_alert.iid.to_s, resolved_alert.iid.to_s]
end end
end end
end end
context 'searching' do context 'searching' do
let(:params) { { search: alert_1.title } } let(:params) { { search: resolved_alert.title } }
it_behaves_like 'a working graphql query' it_behaves_like 'a working graphql query'
it { expect(alerts.size).to eq(1) } it { expect(alerts.size).to eq(1) }
it { expect(first_alert['iid']).to eq(alert_1.iid.to_s) } it { expect(first_alert['iid']).to eq(resolved_alert.iid.to_s) }
context 'unknown criteria' do context 'unknown criteria' do
let(:params) { { search: 'something random' } } let(:params) { { search: 'something random' } }
......
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