Commit 178c00c5 authored by Vitali Tatarintev's avatar Vitali Tatarintev

Return current time when start_time is missing

When the user of the endpoint didn't pass `start_time`,
then the parser will set it to the current time in RFC3339 format.
parent 10379f89
......@@ -16,7 +16,7 @@ module Gitlab
def call
{
'annotations' => annotations,
'startsAt' => payload[:start_time]
'startsAt' => starts_at
}.compact
end
......@@ -41,6 +41,14 @@ module Gitlab
def hosts
payload[:hosts] && Array(payload[:hosts])
end
def starts_at
payload[:start_time].presence || current_time
end
def current_time
Time.now.change(usec: 0).rfc3339
end
end
end
end
......@@ -56,9 +56,10 @@ describe Gitlab::Alerting::NotificationPayloadParser do
context 'when payload is blank' do
let(:payload) { {} }
it 'returns only default title' do
it 'returns default parameters' do
is_expected.to eq(
'annotations' => { 'title' => 'New: Incident' }
'annotations' => { 'title' => 'New: Incident' },
'startsAt' => starts_at.rfc3339
)
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