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