Commit bd0b294f authored by syasonik's avatar syasonik

Move parsing to alert

parent b0e8eb82
......@@ -42,10 +42,6 @@ module Projects
MARKDOWN
end
def alert_markdown
annotations.find { |annotation| annotation.label == 'gitlab_incident_markdown' }&.value
end
private
def alert_title
......
......@@ -49,6 +49,12 @@ module Gitlab
end
end
def alert_markdown
strong_memoize(:alert_markdown) do
parse_alert_markdown_from_payload
end
end
def valid?
project && title && starts_at
end
......@@ -105,6 +111,10 @@ module Gitlab
Rack::Utils.parse_query(uri.query).fetch('g0.expr')
rescue URI::InvalidURIError, KeyError
end
def parse_alert_markdown_from_payload
payload&.dig('annotations', 'gitlab_incident_markdown')
end
end
end
end
......@@ -189,6 +189,12 @@ describe Gitlab::Alerting::Alert do
end
end
describe '#alert_markdown' do
subject { alert.alert_markdown }
it_behaves_like 'parse payload', 'annotations/gitlab_incident_markdown'
end
describe '#valid?' do
before do
payload.update(
......
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