Commit 11c06054 authored by Etienne Baqué's avatar Etienne Baqué

Made some code fixes based on review suggestions

parent 18d877b9
---
title: Fix feature displaying flag names in the audit log
title: Fix displaying feature flag names in the audit log
merge_request: 14621
author:
type: fixed
......@@ -27,15 +27,15 @@ module Audit
case action.keys.first
when :add
"Added #{target_detail_value}#{@details[:as] ? " as #{@details[:as]}" : ''}"
"Added #{target_name}#{@details[:as] ? " as #{@details[:as]}" : ''}"
when :remove
"Removed #{target_detail_value}"
"Removed #{target_name}"
when :failed_login
"Failed to login with #{oath_label} authentication"
when :custom_message
detail_value
else
text_for_change(target_detail_value)
text_for_change(target_name)
end
end
......@@ -48,11 +48,11 @@ module Audit
changed.join(' ')
end
def target_detail_value
@details[:target_type] == 'Operations::FeatureFlag' ? detail_value : detail_value_with_space
def target_name
@details[:target_type] == 'Operations::FeatureFlag' ? detail_value : target_name_with_space
end
def detail_value_with_space
def target_name_with_space
detail_value.tr('_', ' ')
end
......
......@@ -69,26 +69,13 @@ describe Audit::Details do
end
end
context 'feature flag' do
let(:feature_flag) do
{
remove: 'feature_flag',
target_type: 'Operations::FeatureFlag'
}
end
let(:custom_message) { "Removed feature_flag" }
it 'shows message as is' do
string = described_class.humanize(feature_flag)
expect(string).to eq(custom_message)
end
context 'failed_login' do
let(:feature_flag) do
{
failed_login: 'google_oauth2',
target_type: 'Operations::FeatureFlag'
author_name: 'username',
target_details: 'testuser',
ip_address: '127.0.0.1'
}
end
let(:message) { 'Failed to login with GOOGLE authentication' }
......@@ -99,7 +86,6 @@ describe Audit::Details do
expect(string).to eq message
end
end
end
context 'deploy key' do
let(:removal_action) 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