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
d58c9932
Commit
d58c9932
authored
Jul 18, 2019
by
Jason Goodman
Committed by
Bob Van Landuyt
Jul 18, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create an audit event for feature flag scope strategy changes
Create a simple audit message with the raw strategy json
parent
93281427
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
9 deletions
+52
-9
ee/app/services/feature_flags/base_service.rb
ee/app/services/feature_flags/base_service.rb
+2
-1
ee/app/services/feature_flags/update_service.rb
ee/app/services/feature_flags/update_service.rb
+2
-1
ee/changelogs/unreleased/ff-simple-audit-events.yml
ee/changelogs/unreleased/ff-simple-audit-events.yml
+5
-0
ee/spec/services/feature_flags/create_service_spec.rb
ee/spec/services/feature_flags/create_service_spec.rb
+6
-4
ee/spec/services/feature_flags/update_service_spec.rb
ee/spec/services/feature_flags/update_service_spec.rb
+37
-3
No files found.
ee/app/services/feature_flags/base_service.rb
View file @
d58c9932
...
@@ -34,7 +34,8 @@ module FeatureFlags
...
@@ -34,7 +34,8 @@ module FeatureFlags
def
created_scope_message
(
scope
)
def
created_scope_message
(
scope
)
"Created rule <strong>
#{
scope
.
environment_scope
}
</strong> "
\
"Created rule <strong>
#{
scope
.
environment_scope
}
</strong> "
\
"and set it as <strong>
#{
scope
.
active
?
"active"
:
"inactive"
}
</strong>."
"and set it as <strong>
#{
scope
.
active
?
"active"
:
"inactive"
}
</strong> "
\
"with strategies <strong>
#{
scope
.
strategies
}
</strong>."
end
end
end
end
end
end
ee/app/services/feature_flags/update_service.rb
View file @
d58c9932
...
@@ -4,7 +4,8 @@ module FeatureFlags
...
@@ -4,7 +4,8 @@ module FeatureFlags
class
UpdateService
<
FeatureFlags
::
BaseService
class
UpdateService
<
FeatureFlags
::
BaseService
AUDITABLE_SCOPE_ATTRIBUTES_HUMAN_NAMES
=
{
AUDITABLE_SCOPE_ATTRIBUTES_HUMAN_NAMES
=
{
'active'
=>
'active state'
,
'active'
=>
'active state'
,
'environment_scope'
=>
'environment scope'
'environment_scope'
=>
'environment scope'
,
'strategies'
=>
'strategies'
}.
freeze
}.
freeze
def
execute
(
feature_flag
)
def
execute
(
feature_flag
)
...
...
ee/changelogs/unreleased/ff-simple-audit-events.yml
0 → 100644
View file @
d58c9932
---
title
:
Audit strategies for feature flag scopes
merge_request
:
14652
author
:
type
:
added
ee/spec/services/feature_flags/create_service_spec.rb
View file @
d58c9932
...
@@ -47,10 +47,12 @@ describe FeatureFlags::CreateService do
...
@@ -47,10 +47,12 @@ describe FeatureFlags::CreateService do
end
end
it
'creates audit event'
do
it
'creates audit event'
do
expected_message
=
"Created feature flag <strong>feature_flag</strong> "
\
expected_message
=
'Created feature flag <strong>feature_flag</strong> '
\
"with description <strong>
\"
description
\"
</strong>. "
\
'with description <strong>"description"</strong>. '
\
"Created rule <strong>*</strong> and set it as <strong>active</strong>. "
\
'Created rule <strong>*</strong> and set it as <strong>active</strong> '
\
"Created rule <strong>production</strong> and set it as <strong>inactive</strong>."
'with strategies <strong>[{"name"=>"default", "parameters"=>{}}]</strong>. '
\
'Created rule <strong>production</strong> and set it as <strong>inactive</strong> '
\
'with strategies <strong>[{"name"=>"default", "parameters"=>{}}]</strong>.'
expect
{
subject
}.
to
change
{
AuditEvent
.
count
}.
by
(
1
)
expect
{
subject
}.
to
change
{
AuditEvent
.
count
}.
by
(
1
)
expect
(
AuditEvent
.
last
.
present
.
action
).
to
eq
(
expected_message
)
expect
(
AuditEvent
.
last
.
present
.
action
).
to
eq
(
expected_message
)
...
...
ee/spec/services/feature_flags/update_service_spec.rb
View file @
d58c9932
...
@@ -159,10 +159,12 @@ describe FeatureFlags::UpdateService do
...
@@ -159,10 +159,12 @@ describe FeatureFlags::UpdateService do
end
end
it
'creates audit event with new scope'
do
it
'creates audit event with new scope'
do
expected
=
'Created rule <strong>review</strong> and set it as <strong>active</strong> '
\
'with strategies <strong>[{"name"=>"default", "parameters"=>{}}]</strong>.'
subject
subject
expect
(
audit_event_message
).
to
(
include
(
"Created rule <strong>review</strong> and set it as <strong>active</strong>."
)
expect
(
audit_event_message
).
to
include
(
expected
)
)
end
end
context
'when scope can not be created'
do
context
'when scope can not be created'
do
...
@@ -181,5 +183,37 @@ describe FeatureFlags::UpdateService do
...
@@ -181,5 +183,37 @@ describe FeatureFlags::UpdateService do
end
end
end
end
end
end
context
'when the strategy is changed'
do
let
(
:scope
)
do
create
(
:operations_feature_flag_scope
,
feature_flag:
feature_flag
,
environment_scope:
'sandbox'
,
strategies:
[{
name:
"default"
,
parameters:
{}
}])
end
let
(
:params
)
do
{
scopes_attributes:
[{
id:
scope
.
id
,
environment_scope:
'sandbox'
,
strategies:
[{
name:
'gradualRolloutUserId'
,
parameters:
{
groupId:
'mygroup'
,
percentage:
"40"
}
}]
}]
}
end
it
'creates an audit event'
do
expected
=
%r{Updated rule <strong>sandbox</strong> strategies from <strong>.*</strong> to <strong>.*</strong>.}
expect
{
subject
}.
to
change
{
AuditEvent
.
count
}.
by
(
1
)
expect
(
audit_event_message
).
to
match
(
expected
)
end
end
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