diff --git a/ee/app/graphql/mutations/audit_events/external_audit_event_destinations/create.rb b/ee/app/graphql/mutations/audit_events/external_audit_event_destinations/create.rb index 381fcad1de085fbd278c6eb8a66af935aaef3934..eea278f8cb7f8bd357c65277459dc4d689131fe4 100644 --- a/ee/app/graphql/mutations/audit_events/external_audit_event_destinations/create.rb +++ b/ee/app/graphql/mutations/audit_events/external_audit_event_destinations/create.rb @@ -32,7 +32,7 @@ def resolve(destination_url:, group_path:) private def find_object(group_path) - ::GroupFinder.new(current_user).execute(path: group_path) + ::Group.find_by_full_path(group_path) end end end diff --git a/ee/spec/requests/api/graphql/mutations/audit_events/external_audit_event_destinations/create_spec.rb b/ee/spec/requests/api/graphql/mutations/audit_events/external_audit_event_destinations/create_spec.rb index 34e94ae7e92c903d47d86b97c6a5eeae3db7eb79..4a22aebf91daa4ec99c7a76e8f24aa5e1686b607 100644 --- a/ee/spec/requests/api/graphql/mutations/audit_events/external_audit_event_destinations/create_spec.rb +++ b/ee/spec/requests/api/graphql/mutations/audit_events/external_audit_event_destinations/create_spec.rb @@ -5,7 +5,7 @@ RSpec.describe 'Create an external audit event destination' do include GraphqlHelpers - let_it_be(:group) { create(:group) } + let_it_be(:group) { create(:group, :nested) } let_it_be(:owner) { create(:user) } let(:current_user) { owner } @@ -50,6 +50,12 @@ group.add_owner(owner) end + it 'resolves group by full path' do + expect(::Group).to receive(:find_by_full_path).with(group.full_path) + + subject + end + it 'creates the destination' do expect { subject } .to change { AuditEvents::ExternalAuditEventDestination.count }.by(1)