Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
5cc95e50
Commit
5cc95e50
authored
Jul 09, 2019
by
Etienne Baqué
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added char substitution exception for FeatureFlag related event
parent
9f9638a7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
7 deletions
+29
-7
ee/app/helpers/audit_events_helper.rb
ee/app/helpers/audit_events_helper.rb
+7
-2
ee/spec/helpers/audit_events_helper_spec.rb
ee/spec/helpers/audit_events_helper_spec.rb
+22
-5
No files found.
ee/app/helpers/audit_events_helper.rb
View file @
5cc95e50
...
...
@@ -2,8 +2,7 @@
module
AuditEventsHelper
def
human_text
(
details
)
# replace '_' with " " to achive identical behavior with Audit::Details
return
details
[
:custom_message
].
tr
(
'_'
,
' '
)
if
details
[
:custom_message
]
return
custom_message_for
(
details
)
if
details
[
:custom_message
]
details
.
map
{
|
key
,
value
|
select_keys
(
key
,
value
)
}.
join
(
" "
).
humanize
end
...
...
@@ -15,4 +14,10 @@ module AuditEventsHelper
"
#{
key
}
<strong>
#{
value
}
</strong>"
end
end
def
custom_message_for
(
details
)
target_type
=
details
[
:target_type
].
constantize
val
=
details
[
:custom_message
]
target_type
==
Operations
::
FeatureFlag
?
val
:
val
.
tr
(
'_'
,
' '
)
end
end
ee/spec/helpers/audit_events_helper_spec.rb
View file @
5cc95e50
...
...
@@ -2,11 +2,12 @@ require 'spec_helper'
describe
AuditEventsHelper
do
describe
'#human_text'
do
let
(
:target_type
)
{
'User'
}
let
(
:details
)
do
{
author_name:
'John Doe'
,
target_id:
1
,
target_type:
'User'
,
target_type:
target_type
,
target_details:
'Michael'
}
end
...
...
@@ -30,11 +31,27 @@ describe AuditEventsHelper do
expect
(
subject
).
to
eq
(
custom_message
)
end
context
'when
custom message contains "_"
'
do
let
(
:
custom_message
)
{
"message_with_spaces"
}
context
'when
the target_type is Operations::FeatureFlag
'
do
let
(
:
target_type
)
{
'Operations::FeatureFlag'
}
it
'replace them with spaces'
do
expect
(
subject
).
to
eq
(
"message with spaces"
)
context
'when custom message contains "_"'
do
let
(
:custom_message
)
{
"message_with_spaces"
}
it
'does not replace them with spaces'
do
expect
(
subject
).
to
eq
(
"message_with_spaces"
)
end
end
end
context
'when the target_type is not Operations::FeatureFlag'
do
let
(
:target_type
)
{
'User'
}
context
'when custom message contains "_"'
do
let
(
:custom_message
)
{
"message_with_spaces"
}
it
'replaces them with spaces'
do
expect
(
subject
).
to
eq
(
"message with spaces"
)
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment