Commit e17b5ebc authored by Max Woolf's avatar Max Woolf

Merge branch 'fix-audit-event-incorrect-order' into 'master'

Fix incorrect ordering of audit events

See merge request gitlab-org/gitlab!60508
parents b9b6fcc5 9cf33bc7
---
title: Fix incorrect ordering of audit events on MR approval changes
merge_request: 60508
author:
type: fixed
...@@ -50,7 +50,7 @@ module Gitlab ...@@ -50,7 +50,7 @@ module Gitlab
private private
def record def record
events = ::Gitlab::Audit::EventQueue.current.reverse.map(&method(:build_event)) events = ::Gitlab::Audit::EventQueue.current.map { |message| build_event(message) }
log_to_database(events) log_to_database(events)
log_to_file(events) log_to_file(events)
......
...@@ -34,9 +34,9 @@ RSpec.describe Gitlab::Audit::Auditor do ...@@ -34,9 +34,9 @@ RSpec.describe Gitlab::Audit::Auditor do
end end
it 'records audit events in correct order', :aggregate_failures do it 'records audit events in correct order', :aggregate_failures do
expect { auditor.audit(context, &operation) }.to change { AuditEvent.count }.by(2) expect { auditor.audit(context, &operation) }.to change(AuditEvent, :count).by(2)
event_messages = AuditEvent.all.order(created_at: :desc).map { |event| event.details[:custom_message] } event_messages = AuditEvent.all.map { |event| event.details[:custom_message] }
expect(event_messages).to eq([add_message, remove_message]) expect(event_messages).to eq([add_message, remove_message])
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