diff options
Diffstat (limited to 'spec/lib/gitlab/data_builder/alert_spec.rb')
-rw-r--r-- | spec/lib/gitlab/data_builder/alert_spec.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/lib/gitlab/data_builder/alert_spec.rb b/spec/lib/gitlab/data_builder/alert_spec.rb new file mode 100644 index 00000000000..b881fb8139b --- /dev/null +++ b/spec/lib/gitlab/data_builder/alert_spec.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Gitlab::DataBuilder::Alert do + let_it_be(:project) { create(:project) } + let_it_be(:alert) { create(:alert_management_alert, project: project) } + + describe '.build' do + let_it_be(:data) { described_class.build(alert) } + + it { expect(data).to be_a(Hash) } + it { expect(data[:object_kind]).to eq('alert') } + + it 'contains the correct object attributes', :aggregate_failures do + object_attributes = data[:object_attributes] + + expect(object_attributes[:title]).to eq(alert.title) + expect(object_attributes[:url]).to eq(Gitlab::Routing.url_helpers.details_project_alert_management_url(project, alert.iid)) + expect(object_attributes[:severity]).to eq(alert.severity) + expect(object_attributes[:events]).to eq(alert.events) + expect(object_attributes[:status]).to eq(alert.status_name) + expect(object_attributes[:started_at]).to eq(alert.started_at) + end + end +end |