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