Commit 4b6c0b30 authored by Dan Jensen's avatar Dan Jensen Committed by Jarka Košanová

Fix bug with AuditEvent target_id

parent 62dd5e5e
......@@ -13,7 +13,8 @@ module EE
def for_member(member)
action = @details[:action]
old_access_level = @details[:old_access_level]
user_id = member.id
user_id = member.user_id
member_id = member.id
user_name = member.user ? member.user.name : 'Deleted User'
target_type = 'User'
......@@ -24,6 +25,7 @@ module EE
remove: "user_access",
author_name: @author.name,
target_id: user_id,
member_id: member_id,
target_type: target_type,
target_details: user_name
}
......@@ -32,6 +34,7 @@ module EE
remove: "user_access",
author_name: member.created_by ? member.created_by.name : 'Deleted User',
target_id: user_id,
member_id: member_id,
target_type: target_type,
target_details: user_name,
system_event: true,
......@@ -43,6 +46,7 @@ module EE
as: ::Gitlab::Access.options_with_owner.key(member.access_level.to_i),
author_name: @author.name,
target_id: user_id,
member_id: member_id,
target_type: target_type,
target_details: user_name
}
......@@ -55,6 +59,7 @@ module EE
expiry_to: member.expires_at,
author_name: @author.name,
target_id: user_id,
member_id: member_id,
target_type: target_type,
target_details: user_name
}
......
......@@ -22,6 +22,9 @@ RSpec.describe AuditEventService, :request_store do
it 'generates event' do
expect(event_details[:target_details]).to eq(user.name)
expect(event_details[:target_id]).to eq(user.id)
expect(event_details[:target_type]).to eq('User')
expect(event_details[:member_id]).to eq(project_member.id)
end
it 'handles deleted users' 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