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

Use `dig` for Hash lookup

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