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
81416b6f
Commit
81416b6f
authored
Dec 15, 2020
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix feature flag logging is not working on API
parent
c9f1648c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
8 deletions
+25
-8
changelogs/unreleased/fix-feature-api-logging.yml
changelogs/unreleased/fix-feature-api-logging.yml
+5
-0
lib/api/features.rb
lib/api/features.rb
+8
-8
spec/requests/api/features_spec.rb
spec/requests/api/features_spec.rb
+12
-0
No files found.
changelogs/unreleased/fix-feature-api-logging.yml
0 → 100644
View file @
81416b6f
---
title
:
Fix feature flag logging is not working on API
merge_request
:
50025
author
:
type
:
fixed
lib/api/features.rb
View file @
81416b6f
...
...
@@ -75,7 +75,6 @@ module API
post
':name'
do
validate_feature_flag_name!
(
params
[
:name
])
unless
params
[
:force
]
feature
=
Feature
.
get
(
params
[
:name
])
# rubocop:disable Gitlab/AvoidFeatureGet
targets
=
gate_targets
(
params
)
value
=
gate_value
(
params
)
key
=
gate_key
(
params
)
...
...
@@ -83,25 +82,26 @@ module API
case
value
when
true
if
gate_specified?
(
params
)
targets
.
each
{
|
target
|
feature
.
enable
(
target
)
}
targets
.
each
{
|
target
|
Feature
.
enable
(
params
[
:name
],
target
)
}
else
feature
.
enable
Feature
.
enable
(
params
[
:name
])
end
when
false
if
gate_specified?
(
params
)
targets
.
each
{
|
target
|
feature
.
disable
(
target
)
}
targets
.
each
{
|
target
|
Feature
.
disable
(
params
[
:name
],
target
)
}
else
feature
.
disable
Feature
.
disable
(
params
[
:name
])
end
else
if
key
==
:percentage_of_actors
feature
.
enable_percentage_of_actors
(
value
)
Feature
.
enable_percentage_of_actors
(
params
[
:name
],
value
)
else
feature
.
enable_percentage_of_time
(
value
)
Feature
.
enable_percentage_of_time
(
params
[
:name
],
value
)
end
end
present
feature
,
with:
Entities
::
Feature
,
current_user:
current_user
present
Feature
.
get
(
params
[
:name
]),
# rubocop:disable Gitlab/AvoidFeatureGet
with:
Entities
::
Feature
,
current_user:
current_user
end
desc
'Remove the gate value for the given feature'
...
...
spec/requests/api/features_spec.rb
View file @
81416b6f
...
...
@@ -117,6 +117,12 @@ RSpec.describe API::Features, stub_feature_flags: false do
)
end
it
'logs the event'
do
expect
(
Feature
.
logger
).
to
receive
(
:info
).
once
post
api
(
"/features/
#{
feature_name
}
"
,
admin
),
params:
{
value:
'true'
}
end
it
'creates an enabled feature for the given Flipper group when passed feature_group=perf_team'
do
post
api
(
"/features/
#{
feature_name
}
"
,
admin
),
params:
{
value:
'true'
,
feature_group:
'perf_team'
}
...
...
@@ -444,6 +450,12 @@ RSpec.describe API::Features, stub_feature_flags: false do
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
end
it
'logs the event'
do
expect
(
Feature
.
logger
).
to
receive
(
:info
).
once
delete
api
(
"/features/
#{
feature_name
}
"
,
admin
)
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