Commit 7be7c444 authored by syasonik's avatar syasonik

Port Processer api refactor from CE

parent 5d3e42fa
......@@ -4,8 +4,8 @@ module EE
module Gitlab
module MetricsDashboard
module Processor
def stages
@stages ||= super + [Stages::AlertsInserter]
def sequence
super + [Stages::AlertsInserter]
end
end
end
......
......@@ -7,10 +7,10 @@ module EE
module MetricsDashboard
module Stages
class AlertsInserter < ::Gitlab::MetricsDashboard::Stages::BaseStage
def transform!
def transform!(dashboard)
return if metrics_with_alerts.empty?
for_metrics do |metric|
for_metrics(dashboard) do |metric|
next unless metrics_with_alerts.include?(metric[:metric_id])
metric[:alert_path] = alert_path(metric[:metric_id], project, environment)
......
......@@ -7,19 +7,19 @@ describe Gitlab::MetricsDashboard::Processor do
let(:environment) { create(:environment, project: project) }
let(:dashboard_yml) { YAML.load_file('spec/fixtures/lib/gitlab/metrics_dashboard/sample_dashboard.yml') }
describe 'stages' do
describe 'sequence' do
let(:environment) { build(:environment) }
let(:process_params) { [dashboard_yml, project, environment] }
let(:stages) { described_class.new(*process_params).stages }
let(:process_params) { [project, environment] }
let(:sequence) { described_class.new(*process_params).sequence }
it 'includes the alerts processing stage' do
expect(stages.length).to eq(4)
expect(sequence.length).to eq(4)
end
end
describe 'process' do
let(:process_params) { [dashboard_yml, project, environment] }
let(:dashboard) { described_class.new(*process_params).process }
let(:process_params) { [project, environment] }
let(:dashboard) { described_class.new(*process_params).process(dashboard_yml) }
context 'when the dashboard references persisted metrics with alerts' do
let!(:alert) do
......
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