Commit a1f9a68d authored by Stan Hu's avatar Stan Hu

Merge branch '346766-audit-event-no-entity' into 'master'

Handle event streaming licence error when no entity

See merge request gitlab-org/gitlab!75522
parents afd69325 581dd9b8
......@@ -57,7 +57,7 @@ module EE
def stream_to_external_destinations
return if entity.nil?
return unless ::Feature.enabled?(:ff_external_audit_events_namespace, group_entity)
return unless group_entity.licensed_feature_available?(:external_audit_events)
return unless group_entity&.licensed_feature_available?(:external_audit_events)
AuditEvents::AuditEventStreamingWorker.perform_async(id)
end
......
......@@ -101,6 +101,20 @@ RSpec.describe AuditEvent, type: :model do
event.stream_to_external_destinations
end
context 'when entity is not a group or project' do
let_it_be(:event) { create(:user_audit_event) }
before do
stub_feature_flags(ff_external_audit_events_namespace: true)
end
it 'enqueues no workers' do
expect(AuditEvents::AuditEventStreamingWorker).not_to receive(:perform_async)
event.stream_to_external_destinations
end
end
end
context 'when ff_external_audit_events_namespace is disabled' 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