summaryrefslogtreecommitdiff
path: root/spec/serializers/prometheus_alert_entity_spec.rb
blob: ae8c97401f869cb78c6ea50d3c446c9fd44ab000 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe PrometheusAlertEntity do
  let(:user) { create(:user) }
  let(:prometheus_alert) { create(:prometheus_alert) }
  let(:request) { double('prometheus_alert', current_user: user) }
  let(:entity) { described_class.new(prometheus_alert, request: request) }

  subject { entity.as_json }

  context 'when user can read prometheus alerts' do
    before do
      prometheus_alert.project.add_maintainer(user)
    end

    it 'exposes prometheus_alert attributes' do
      expect(subject).to include(:id, :title, :query, :operator, :threshold, :runbook_url)
    end

    it 'exposes alert_path' do
      expect(subject).to include(:alert_path)
    end
  end
end