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