Commit 44360af0 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'ajk-alert-management-base' into 'master'

Remove re-use of resolver in mutation

See merge request gitlab-org/gitlab!47246
parents daf806b8 7c434021
...@@ -4,7 +4,6 @@ module Mutations ...@@ -4,7 +4,6 @@ module Mutations
module AlertManagement module AlertManagement
class Base < BaseMutation class Base < BaseMutation
include Gitlab::Utils::UsageData include Gitlab::Utils::UsageData
include ResolvesProject
argument :project_path, GraphQL::ID_TYPE, argument :project_path, GraphQL::ID_TYPE,
required: true, required: true,
...@@ -33,13 +32,12 @@ module Mutations ...@@ -33,13 +32,12 @@ module Mutations
private private
def find_object(project_path:, iid:) def find_object(project_path:, **args)
project = resolve_project(full_path: project_path) project = Project.find_by_full_path(project_path)
return unless project return unless project
resolver = Resolvers::AlertManagement::AlertResolver.single.new(object: project, context: context, field: nil) ::AlertManagement::AlertsFinder.new(current_user, project, args).execute.first
resolver.resolve(iid: iid)
end end
end end
end end
......
...@@ -9,9 +9,9 @@ module Mutations ...@@ -9,9 +9,9 @@ module Mutations
required: true, required: true,
description: 'The status to set the alert' description: 'The status to set the alert'
def resolve(args) def resolve(project_path:, iid:, status:)
alert = authorized_find!(project_path: args[:project_path], iid: args[:iid]) alert = authorized_find!(project_path: project_path, iid: iid)
result = update_status(alert, args[:status]) result = update_status(alert, status)
track_usage_event(:incident_management_alert_status_changed, current_user.id) track_usage_event(:incident_management_alert_status_changed, current_user.id)
......
...@@ -37,8 +37,8 @@ RSpec.describe Mutations::AlertManagement::UpdateAlertStatus do ...@@ -37,8 +37,8 @@ RSpec.describe Mutations::AlertManagement::UpdateAlertStatus do
context 'error occurs when updating' do context 'error occurs when updating' do
it 'returns the alert with errors' do it 'returns the alert with errors' do
# Stub an error on the alert # Stub an error on the alert
allow_next_instance_of(Resolvers::AlertManagement::AlertResolver) do |resolver| allow_next_instance_of(::AlertManagement::AlertsFinder) do |finder|
allow(resolver).to receive(:resolve).and_return(alert) allow(finder).to receive(:execute).and_return([alert])
end end
allow(alert).to receive(:save).and_return(false) allow(alert).to receive(:save).and_return(false)
......
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