Commit 714454c1 authored by Vitali Tatarintev's avatar Vitali Tatarintev

Use `dig` for Hash lookup

parent 6ece98d2
......@@ -39,7 +39,7 @@ module Gitlab
end
def hosts
payload[:hosts] && Array(payload[:hosts])
payload[:hosts].presence && Array(payload[:hosts])
end
def current_time
......
......@@ -39,7 +39,7 @@ describe Gitlab::Alerting::NotificationPayloadParser do
end
it 'sets a predefined title' do
expect(subject['annotations']['title']).to eq('New: Incident')
expect(subject.dig('annotations', 'title')).to eq('New: Incident')
end
end
......@@ -49,7 +49,7 @@ describe Gitlab::Alerting::NotificationPayloadParser do
end
it 'returns hosts as an array of one element' do
expect(subject['annotations']['hosts']).to eq(['gitlab.com'])
expect(subject.dig('annotations', 'hosts')).to eq(['gitlab.com'])
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