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