debian-mirror-gitlab/spec/models/project_services/alerts_service_spec.rb

40 lines
1 KiB
Ruby
Raw Normal View History

2020-03-13 15:44:24 +05:30
# frozen_string_literal: true
require 'spec_helper'
2021-03-08 18:12:59 +05:30
# AlertsService is stripped down to only required methods
# to avoid errors loading integration-related pages if
# records are present.
2020-07-28 23:09:34 +05:30
RSpec.describe AlertsService do
2020-03-13 15:44:24 +05:30
let_it_be(:project) { create(:project) }
2021-03-08 18:12:59 +05:30
subject(:service) { described_class.new(project: project) }
2020-03-13 15:44:24 +05:30
2021-03-08 18:12:59 +05:30
it { is_expected.to be_valid }
2020-03-13 15:44:24 +05:30
2021-03-08 18:12:59 +05:30
describe '#to_param' do
subject { service.to_param }
2020-03-13 15:44:24 +05:30
2021-03-08 18:12:59 +05:30
it { is_expected.to eq('alerts') }
2020-03-13 15:44:24 +05:30
end
2021-03-08 18:12:59 +05:30
describe '#supported_events' do
subject { service.supported_events }
2020-03-13 15:44:24 +05:30
2021-03-08 18:12:59 +05:30
it { is_expected.to be_empty }
2020-03-13 15:44:24 +05:30
end
2021-03-08 18:12:59 +05:30
describe '#save' do
it 'prevents records from being created or updated' do
expect(Gitlab::ProjectServiceLogger).to receive(:error).with(
hash_including(message: 'Prevented attempt to save or update deprecated AlertsService')
)
2020-03-13 15:44:24 +05:30
2021-03-08 18:12:59 +05:30
expect(service.save).to be_falsey
2020-03-13 15:44:24 +05:30
2021-03-08 18:12:59 +05:30
expect(service.errors.full_messages).to include(
'Alerts endpoint is deprecated and should not be created or modified. Use HTTP Integrations instead.'
)
2020-03-13 15:44:24 +05:30
end
end
end