Commit 4d2caa25 authored by Sean Arnold's avatar Sean Arnold

Update variables and specs

- Update URL helper
parent 786a5a45
......@@ -48,10 +48,9 @@ module AlertManagement
private
def details_url
::Gitlab::Routing.url_helpers.details_namespace_project_alert_management_url(
id: alert,
project_id: project,
namespace_id: project.namespace
::Gitlab::Routing.url_helpers.details_project_alert_management_url(
project,
alert.iid
)
end
......
......@@ -78,12 +78,11 @@ module Projects
end
def details_url
return unless alert
return unless am_alert
::Gitlab::Routing.url_helpers.details_namespace_project_alert_management_url(
id: alert,
project_id: project,
namespace_id: project.namespace
::Gitlab::Routing.url_helpers.details_project_alert_management_url(
project,
am_alert.iid
)
end
......
......@@ -14,7 +14,7 @@ module IncidentManagement
def execute
return error('setting disabled') unless incident_management_setting.create_issue?
return error('invalid alert') unless presented_alert.valid?
return error('invalid alert') unless alert_presenter.valid?
result = create_incident
return error(result.message, result.payload[:issue]) unless result.success?
......@@ -34,7 +34,7 @@ module IncidentManagement
end
def issue_title
presented_alert.full_title
alert_presenter.full_title
end
def issue_description
......@@ -48,15 +48,15 @@ module IncidentManagement
end
def alert_summary
presented_alert.issue_summary_markdown
alert_presenter.issue_summary_markdown
end
def alert_markdown
presented_alert.alert_markdown
alert_presenter.alert_markdown
end
def presented_alert
strong_memoize(:presented_alert) do
def alert_presenter
strong_memoize(:alert_presenter) do
Gitlab::Alerting::Alert.for_alert_management_alert(project: project, alert: alert).present
end
end
......
......@@ -7,7 +7,7 @@ module Gitlab
include Gitlab::Utils::StrongMemoize
include Presentable
attr_accessor :project, :payload, :alert
attr_accessor :project, :payload, :am_alert
def self.for_alert_management_alert(project:, alert:)
params = if alert.prometheus?
......@@ -16,7 +16,7 @@ module Gitlab
Gitlab::Alerting::NotificationPayloadParser.call(alert.payload.to_h, alert.project)
end
self.new(project: project, payload: params, alert: alert)
self.new(project: project, payload: params, am_alert: alert)
end
def gitlab_alert
......
......@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe AlertManagement::AlertPresenter do
let_it_be(:project) { create(:project) }
let(:generic_payload) do
let_it_be(:generic_payload) do
{
'title' => 'Alert title',
'start_time' => '2020-04-27T10:10:22.265949279Z',
......@@ -18,7 +18,7 @@ RSpec.describe AlertManagement::AlertPresenter do
build(:alert_management_alert, :with_description, :with_host, :with_service, :with_monitoring_tool, project: project, payload: generic_payload)
end
let(:alert_url) { "http://localhost/#{project.full_path}/-/alert_management/#{alert.id}/details" }
let(:alert_url) { "http://localhost/#{project.full_path}/-/alert_management/#{alert.iid}/details" }
subject(:presenter) { described_class.new(alert) }
......
......@@ -20,7 +20,7 @@ RSpec.describe AlertManagement::PrometheusAlertPresenter do
create(:alert_management_alert, :prometheus, project: project, payload: payload)
end
let(:alert_url) { "http://localhost/#{project.full_path}/-/alert_management/#{alert.id}/details" }
let(:alert_url) { "http://localhost/#{project.full_path}/-/alert_management/#{alert.iid}/details" }
subject(:presenter) { described_class.new(alert) }
......
......@@ -300,9 +300,9 @@ RSpec.describe Projects::Prometheus::AlertPresenter do
context 'alert management alert present' do
let_it_be(:am_alert) { create(:alert_management_alert, project: project) }
let(:alert) { create(:alerting_alert, project: project, payload: payload, alert: am_alert) }
let(:alert) { create(:alerting_alert, project: project, payload: payload, am_alert: am_alert) }
it { is_expected.to eq("http://localhost/#{project.full_path}/-/alert_management/#{am_alert.id}/details") }
it { is_expected.to eq("http://localhost/#{project.full_path}/-/alert_management/#{am_alert.iid}/details") }
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