Commit 15df6af2 authored by James Lopez's avatar James Lopez

refactor audit changes after merge, fixed spec

parent 82f5cd46
......@@ -16,21 +16,6 @@ class AuditEventService
self
end
def for_changes
@details =
{
change: @details[:as] || @details[:column],
from: @details[:from],
to: @details[:to],
author_name: @author.name,
target_id: @entity.id,
target_type: @entity.class,
target_details: @entity.name
}
self
end
def security_event
SecurityEvent.create(
author_id: @author.id,
......
......@@ -17,8 +17,8 @@ module Users
user_exists = @user.persisted?
if @user.save(validate: validate)
audit_changes :email, as: 'email address', column: :notification_email
audit_changes :encrypted_password, as: 'password', skip_changes: true
audit_changes(:email, as: 'email address', column: :notification_email)
audit_changes(:encrypted_password, as: 'password', skip_changes: true)
notify_new_user(@user, nil) unless user_exists
......
......@@ -82,6 +82,20 @@ module EE
self
end
def for_changes
@details =
{
change: @details[:as] || @details[:column],
from: @details[:from],
to: @details[:to],
author_name: @author.name,
target_id: @entity.id,
target_type: @entity.class,
target_details: @entity.name
}
self
end
def security_event
if admin_audit_log_enabled?
add_security_event_admin_details!
......
......@@ -38,7 +38,7 @@ module EE
end
def audit_event(options)
AuditEventService.new(@current_user, model, options).
::AuditEventService.new(@current_user, model, options).
for_changes.security_event
end
end
......
......@@ -203,7 +203,6 @@ describe Gitlab::LDAP::Access do
it 'updates email address' do
expect(access).to receive(:update_email).once
expect(AuditEvents.count).to eq(1)
subject
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