Commit 81416b6f authored by Shinya Maeda's avatar Shinya Maeda

Fix feature flag logging is not working on API

parent c9f1648c
---
title: Fix feature flag logging is not working on API
merge_request: 50025
author:
type: fixed
......@@ -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'
......
......@@ -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
......
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