Commit 196b1112 authored by Nick Thomas's avatar Nick Thomas

Merge branch '200010-move-alerts-notify-endpoint-to-ce' into 'master'

Move the Generic Alerts endpoint to the Core

Closes #200010

See merge request gitlab-org/gitlab!24783
parents d816489a 67444f1b
......@@ -138,6 +138,7 @@ class Project < ApplicationRecord
has_many :boards
# Project services
has_one :alerts_service
has_one :campfire_service
has_one :discord_service
has_one :drone_ci_service
......@@ -2330,6 +2331,10 @@ class Project < ApplicationRecord
protected_branches.limit(limit)
end
def alerts_service_activated?
false
end
private
def closest_namespace_setting(name)
......
......@@ -323,6 +323,8 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
end
post 'alerts/notify', to: 'alerting/notifications#create'
resources :pipelines, only: [:index, :new, :create, :show, :destroy] do
collection do
resource :pipelines_settings, path: 'settings', only: [:show, :update]
......
......@@ -44,7 +44,6 @@ module EE
has_one :jenkins_deprecated_service
has_one :github_service
has_one :gitlab_slack_application_service
has_one :alerts_service
has_one :service_desk_setting, class_name: 'ServiceDeskSetting'
has_one :tracing_setting, class_name: 'ProjectTracingSetting'
......@@ -688,6 +687,7 @@ module EE
feature_available?(:incident_management)
end
override :alerts_service_activated?
def alerts_service_activated?
alerts_service_available? && alerts_service&.active?
end
......
......@@ -127,8 +127,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
end
post 'alerts/notify', to: 'alerting/notifications#create'
resource :tracing, only: [:show]
resources :web_ide_terminals, path: :ide_terminals, only: [:create, :show], constraints: { id: /\d+/, format: :json } do
......
......@@ -7,16 +7,6 @@ FactoryBot.define do
type { 'GitlabSlackApplicationService' }
end
factory :alerts_service do
project
type { 'AlertsService' }
active { true }
trait :inactive do
active { false }
end
end
factory :github_service do
project
active { true }
......
......@@ -44,6 +44,16 @@ FactoryBot.define do
end
end
factory :alerts_service do
project
type { 'AlertsService' }
active { true }
trait :inactive do
active { false }
end
end
factory :drone_ci_service do
project
active { true }
......
......@@ -5584,6 +5584,14 @@ describe Project do
end
end
describe '#alerts_service_activated?' do
let!(:project) { create(:project) }
subject { project.alerts_service_activated? }
it { is_expected.to be_falsey }
end
def rugged_config
rugged_repo(project.repository).config
end
......
# frozen_string_literal: true
require 'spec_helper'
describe Projects::Alerting::NotifyService do
let_it_be(:project, reload: true) { create(:project) }
shared_examples 'does not process incident issues' do |http_status:|
it 'does not process issues' do
expect(IncidentManagement::ProcessAlertWorker)
.not_to receive(:perform_async)
expect(subject.status).to eq(:error)
expect(subject.http_status).to eq(http_status)
end
end
describe '#execute' do
let(:token) { 'invalid-token' }
let(:starts_at) { Time.now.change(usec: 0) }
let(:service) { described_class.new(project, nil, payload) }
let(:payload_raw) do
{
'title' => 'alert title',
'start_time' => starts_at.rfc3339
}
end
let(:payload) { ActionController::Parameters.new(payload_raw).permit! }
subject { service.execute(token) }
it_behaves_like 'does not process incident issues', http_status: 403
end
end
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