Skip to content
Snippets Groups Projects
Verified Commit 9d73f471 authored by Huzaifa Iftikhar's avatar Huzaifa Iftikhar :baby: Committed by GitLab
Browse files

Merge branch 'sf/feature/add-role-to-audit-dashboard-display-448797' into 'master'

Add humanized role to removal events in audit details

See merge request !147435



Merged-by: default avatarHuzaifa Iftikhar <hiftikhar@gitlab.com>
Approved-by: default avatarDmytro Biryukov <dbiryukov@gitlab.com>
Approved-by: default avatarHuzaifa Iftikhar <hiftikhar@gitlab.com>
Reviewed-by: default avatarHuzaifa Iftikhar <hiftikhar@gitlab.com>
Co-authored-by: default avatarSam Figueroa <sfigueroa@gitlab.com>
parents d5fff6bb bb18b609
No related branches found
No related tags found
1 merge request!147435Add humanized role to removal events in audit details
Pipeline #1244119298 passed
......@@ -39,9 +39,9 @@ def action_text
case action_name.to_sym
when :add
"Added #{target_name}#{@details[:as] ? " as #{@details[:as]}" : ''}"
"Added #{target_name}#{@details[:as] && " as #{@details[:as]}"}"
when :remove
"Removed #{target_name}"
"Removed #{target_name}#{@details[:as] && " as #{@details[:as]}"}"
when :failed_login
"Failed to login with #{oauth_label} authentication"
when :updated_ref
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe Audit::Details do
RSpec.describe Audit::Details, feature_category: :compliance_management do
let(:user) { create(:user) }
describe '.humanize' do
......@@ -63,6 +63,61 @@
expect(string).to eq('Added user access as Developer')
end
context "without role" do
let(:member_access_action) do
{
add: 'user_access',
author_name: user.name,
target_id: member.id,
target_type: 'User',
target_details: member.user.name
}
end
it 'humanizes add project member access action without mentioning role' do
string = described_class.humanize(member_access_action)
expect(string).to eq('Added user access')
end
end
end
context 'remove member' do
let(:member_access_action) do
{
remove: 'user_access',
as: Gitlab::Access.options_with_owner.key(member.access_level.to_i),
author_name: user.name,
target_id: member.id,
target_type: 'User',
target_details: member.user.name
}
end
it 'humanizes the removal with role' do
expect(described_class.humanize(member_access_action)).to eq(
'Removed user access as Developer'
)
end
context "without role" do
let(:member_access_action) do
{
remove: 'user_access',
author_name: user.name,
target_id: member.id,
target_type: 'User',
target_details: member.user.name
}
end
it 'humanizes the removal without mentioning role' do
expect(described_class.humanize(member_access_action)).to eq(
'Removed user access'
)
end
end
end
context 'update project member' do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment