Commit f64c4df1 authored by Mikołaj Wawrzyniak's avatar Mikołaj Wawrzyniak

Merge branch 'mw/handle-null-entity-audit-event-streaming' into 'master'

Handle event streaming when entity does not exist

See merge request gitlab-org/gitlab!74819
parents 750aa130 3ee8ed30
......@@ -15,6 +15,9 @@ module AuditEvents
def perform(audit_event_id)
audit_event = AuditEvent.find(audit_event_id)
return if audit_event.entity.nil?
group = group_entity(audit_event)
return if group.nil? # Do nothing if the event can't be resolved to a single group.
......
......@@ -97,5 +97,19 @@ RSpec.describe AuditEvents::AuditEventStreamingWorker do
worker.perform(event.id)
end
end
context 'when the entity is a NullEntity' do
let_it_be(:event) { create(:audit_event, :project_event) }
before do
event.entity_id = non_existing_record_id
end
it 'makes no HTTP calls' do
expect(Gitlab::HTTP).not_to receive(:post)
worker.perform(event.id)
end
end
end
end
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