Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-08-07 15:09:59 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-08-07 15:09:59 +0300
commit5958e399de2e45d509f25b9c84b0a4d7bafa41a1 (patch)
tree9f6fe0f418fe7fd1b3dc823c831b775708de8c84 /spec/presenters
parent277fdda606a023c1f8fa631e6a5c6868287caf36 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/presenters')
-rw-r--r--spec/presenters/alert_management/alert_presenter_spec.rb14
-rw-r--r--spec/presenters/alert_management/prometheus_alert_presenter_spec.rb16
2 files changed, 26 insertions, 4 deletions
diff --git a/spec/presenters/alert_management/alert_presenter_spec.rb b/spec/presenters/alert_management/alert_presenter_spec.rb
index b1bf7029f3e..ccea0d36a28 100644
--- a/spec/presenters/alert_management/alert_presenter_spec.rb
+++ b/spec/presenters/alert_management/alert_presenter_spec.rb
@@ -8,11 +8,12 @@ RSpec.describe AlertManagement::AlertPresenter do
{
'title' => 'Alert title',
'start_time' => '2020-04-27T10:10:22.265949279Z',
- 'custom' => { 'param' => 73 }
+ 'custom' => { 'param' => 73 },
+ 'runbook' => 'https://runbook.com'
}
end
let_it_be(:alert) do
- create(:alert_management_alert, :with_description, :with_host, :with_service, :with_monitoring_tool, project: project, payload: generic_payload)
+ build(:alert_management_alert, :with_description, :with_host, :with_service, :with_monitoring_tool, project: project, payload: generic_payload)
end
subject(:presenter) { described_class.new(alert) }
@@ -34,7 +35,8 @@ RSpec.describe AlertManagement::AlertPresenter do
#### Alert Details
- **custom.param:** 73
+ **custom.param:** 73#{markdown_line_break}
+ **runbook:** https://runbook.com
MARKDOWN
)
end
@@ -45,4 +47,10 @@ RSpec.describe AlertManagement::AlertPresenter do
expect(presenter.metrics_dashboard_url).to be_nil
end
end
+
+ describe '#runbook' do
+ it 'shows the runbook from the payload' do
+ expect(presenter.runbook).to eq('https://runbook.com')
+ end
+ end
end
diff --git a/spec/presenters/alert_management/prometheus_alert_presenter_spec.rb b/spec/presenters/alert_management/prometheus_alert_presenter_spec.rb
index 95246914140..70c85619fd1 100644
--- a/spec/presenters/alert_management/prometheus_alert_presenter_spec.rb
+++ b/spec/presenters/alert_management/prometheus_alert_presenter_spec.rb
@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe AlertManagement::PrometheusAlertPresenter do
let_it_be(:project) { create(:project) }
- let_it_be(:payload) do
+ let(:payload) do
{
'annotations' => {
'title' => 'Alert title',
@@ -15,6 +15,7 @@ RSpec.describe AlertManagement::PrometheusAlertPresenter do
'generatorURL' => 'http://8d467bd4607a:9090/graph?g0.expr=vector%281%29&g0.tab=1'
}
end
+
let(:alert) do
create(:alert_management_alert, :prometheus, project: project, payload: payload)
end
@@ -65,4 +66,17 @@ RSpec.describe AlertManagement::PrometheusAlertPresenter do
it { is_expected.to eq(dashboard_url_for_alert) }
end
end
+
+ describe '#runbook' do
+ subject { presenter.runbook }
+
+ it { is_expected.to be_nil }
+
+ context 'with runbook in payload' do
+ let(:expected_runbook) { 'https://awesome-runbook.com' }
+ let(:payload) { { 'annotations' => { 'runbook' => expected_runbook } } }
+
+ it { is_expected.to eq(expected_runbook) }
+ end
+ end
end