Commit 31e419e9 authored by Ash McKenzie's avatar Ash McKenzie

Add new Feature.remove method

parent a4e08446
...@@ -80,6 +80,13 @@ class Feature ...@@ -80,6 +80,13 @@ class Feature
get(key).disable_group(group) get(key).disable_group(group)
end end
def remove(key)
feature = get(key)
return unless persisted?(feature)
feature.remove
end
def flipper def flipper
if Gitlab::SafeRequestStore.active? if Gitlab::SafeRequestStore.active?
Gitlab::SafeRequestStore[:flipper] ||= build_flipper_instance Gitlab::SafeRequestStore[:flipper] ||= build_flipper_instance
......
...@@ -254,6 +254,22 @@ describe Feature do ...@@ -254,6 +254,22 @@ describe Feature do
end end
end end
describe '.remove' do
context 'for a non-persisted feature' do
it 'returns nil' do
expect(described_class.remove(:non_persisted_feature_flag)).to be_nil
end
end
context 'for a persisted feature' do
it 'returns true' do
described_class.enable(:persisted_feature_flag)
expect(described_class.remove(:persisted_feature_flag)).to be_truthy
end
end
end
describe Feature::Target do describe Feature::Target do
describe '#targets' do describe '#targets' do
let(:project) { create(:project) } let(:project) { create(:project) }
......
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