diff --git a/ee/app/services/ee/projects/destroy_service.rb b/ee/app/services/ee/projects/destroy_service.rb index fc06e6cda370fe05d4db3ca44cbc7e883e9dfd2f..12f27513bdfb10c4190ac3119122b85b1d1126e5 100644 --- a/ee/app/services/ee/projects/destroy_service.rb +++ b/ee/app/services/ee/projects/destroy_service.rb @@ -81,10 +81,12 @@ def log_geo_event(project) end def log_audit_event(project) + audit_scope = project.parent.instance_of?(::Namespaces::UserNamespace) ? project.parent.owner : project.parent + audit_context = { name: 'project_destroyed', author: current_user, - scope: project.parent, + scope: audit_scope, target: project, message: 'Project destroyed', target_details: project.full_path, diff --git a/ee/spec/services/projects/destroy_service_spec.rb b/ee/spec/services/projects/destroy_service_spec.rb index 56cc91ae5103d486005dc34dabcb1fd2d94d4d53..3825800bc08da7012d05d72623cc12638bcd919b 100644 --- a/ee/spec/services/projects/destroy_service_spec.rb +++ b/ee/spec/services/projects/destroy_service_spec.rb @@ -169,8 +169,8 @@ let(:attributes) do { author_id: user.id, - entity_id: project.parent.id, - entity_type: 'Namespaces::UserNamespace', + entity_id: user.id, + entity_type: 'User', details: { remove: 'project', author_name: user.name, @@ -249,6 +249,7 @@ context 'system hooks exception' do before do allow_any_instance_of(SystemHooksService).to receive(:execute_hooks_for).and_raise('something went wrong') + stub_licensed_features(extended_audit_events: true) end it 'logs an audit event' do