Commit d1dccaa4 authored by Vitali Tatarintev's avatar Vitali Tatarintev

Merge branch '216672-prometheus-service' into 'master'

Inherit BaseProjectService for prometheus services

See merge request gitlab-org/gitlab!74676
parents 20bf2b40 ade38e8f
...@@ -82,17 +82,17 @@ module Projects ...@@ -82,17 +82,17 @@ module Projects
def create_service def create_service
Projects::Prometheus::Alerts::CreateService Projects::Prometheus::Alerts::CreateService
.new(project, current_user, alerts_params) .new(project: project, current_user: current_user, params: alerts_params)
end end
def update_service def update_service
Projects::Prometheus::Alerts::UpdateService Projects::Prometheus::Alerts::UpdateService
.new(project, current_user, alerts_params) .new(project: project, current_user: current_user, params: alerts_params)
end end
def destroy_service def destroy_service
Projects::Prometheus::Alerts::DestroyService Projects::Prometheus::Alerts::DestroyService
.new(project, current_user, nil) .new(project: project, current_user: current_user, params: nil)
end end
def schedule_prometheus_update! def schedule_prometheus_update!
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
module Projects module Projects
module Prometheus module Prometheus
module Alerts module Alerts
class CreateService < BaseService class CreateService < BaseProjectService
include AlertParams include AlertParams
def execute def execute
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
module Projects module Projects
module Prometheus module Prometheus
module Alerts module Alerts
class DestroyService < BaseService class DestroyService < BaseProjectService
def execute(alert) def execute(alert)
alert.destroy alert.destroy
end end
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
module Projects module Projects
module Prometheus module Prometheus
module Alerts module Alerts
class UpdateService < BaseService class UpdateService < BaseProjectService
include AlertParams include AlertParams
def execute(alert) def execute(alert)
......
...@@ -6,7 +6,7 @@ RSpec.describe Projects::Prometheus::Alerts::CreateService do ...@@ -6,7 +6,7 @@ RSpec.describe Projects::Prometheus::Alerts::CreateService do
let_it_be(:project) { create(:project) } let_it_be(:project) { create(:project) }
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let(:service) { described_class.new(project, user, params) } let(:service) { described_class.new(project: project, current_user: user, params: params) }
subject { service.execute } subject { service.execute }
......
...@@ -7,7 +7,7 @@ RSpec.describe Projects::Prometheus::Alerts::DestroyService do ...@@ -7,7 +7,7 @@ RSpec.describe Projects::Prometheus::Alerts::DestroyService do
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let_it_be(:alert) { create(:prometheus_alert, project: project) } let_it_be(:alert) { create(:prometheus_alert, project: project) }
let(:service) { described_class.new(project, user, nil) } let(:service) { described_class.new(project: project, current_user: user, params: nil) }
describe '#execute' do describe '#execute' do
subject { service.execute(alert) } subject { service.execute(alert) }
......
...@@ -11,7 +11,7 @@ RSpec.describe Projects::Prometheus::Alerts::UpdateService do ...@@ -11,7 +11,7 @@ RSpec.describe Projects::Prometheus::Alerts::UpdateService do
create(:prometheus_alert, project: project, environment: environment) create(:prometheus_alert, project: project, environment: environment)
end end
let(:service) { described_class.new(project, user, params) } let(:service) { described_class.new(project: project, current_user: user, params: params) }
let(:params) do let(:params) do
{ {
......
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