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

update_alert_status_service_spec.rb « alert_management « services « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4408312845313903fe99d833eac2b5a8bd01da2c (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
27
28
29
# frozen_string_literal: true

require 'spec_helper'

describe AlertManagement::UpdateAlertStatusService do
  let_it_be(:alert) { create(:alert_management_alert, status: 'triggered') }

  describe '#execute' do
    subject(:execute) { described_class.new(alert, new_status).execute }

    let(:new_status) { Types::AlertManagement::StatusEnum.values['ACKNOWLEDGED'].value }

    it 'updates the status' do
      expect { execute }.to change { alert.acknowledged? }.to(true)
    end

    context 'with unknown status' do
      let(:new_status) { 'random_status' }

      it 'returns an error' do
        expect(execute.status).to eq(:error)
      end

      it 'does not update the status' do
        expect { execute }.not_to change { alert.status }
      end
    end
  end
end