diff options
Diffstat (limited to 'spec/lib/gitlab/alerting/notification_payload_parser_spec.rb')
-rw-r--r-- | spec/lib/gitlab/alerting/notification_payload_parser_spec.rb | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/spec/lib/gitlab/alerting/notification_payload_parser_spec.rb b/spec/lib/gitlab/alerting/notification_payload_parser_spec.rb index 0489108b159..ff5ab1116fa 100644 --- a/spec/lib/gitlab/alerting/notification_payload_parser_spec.rb +++ b/spec/lib/gitlab/alerting/notification_payload_parser_spec.rb @@ -7,10 +7,12 @@ RSpec.describe Gitlab::Alerting::NotificationPayloadParser do describe '.call' do let(:starts_at) { Time.current.change(usec: 0) } + let(:ends_at) { Time.current.change(usec: 0) } let(:payload) do { 'title' => 'alert title', 'start_time' => starts_at.rfc3339, + 'end_time' => ends_at.rfc3339, 'description' => 'Description', 'monitoring_tool' => 'Monitoring tool name', 'service' => 'Service', @@ -32,7 +34,8 @@ RSpec.describe Gitlab::Alerting::NotificationPayloadParser do 'hosts' => ['gitlab.com'], 'severity' => 'low' }, - 'startsAt' => starts_at.rfc3339 + 'startsAt' => starts_at.rfc3339, + 'endsAt' => ends_at.rfc3339 } ) end @@ -124,11 +127,24 @@ RSpec.describe Gitlab::Alerting::NotificationPayloadParser do end end + context 'with environment' do + let(:environment) { create(:environment, project: project) } + + before do + payload[:gitlab_environment_name] = environment.name + end + + it 'sets the environment ' do + expect(subject.dig('annotations', 'environment')).to eq(environment) + end + end + context 'when payload attributes have blank lines' do let(:payload) do { 'title' => '', 'start_time' => '', + 'end_time' => '', 'description' => '', 'monitoring_tool' => '', 'service' => '', |