Merge branch '65363-add-feature-remove' into 'master'

Add Feature.remove

Closes #65363

See merge request gitlab-org/gitlab-ce!31315
This commit is contained in:
Stan Hu 2019-08-01 00:02:07 +00:00
commit cfb7f11644
2 changed files with 23 additions and 0 deletions

View file

@ -80,6 +80,13 @@ class Feature
get(key).disable_group(group)
end
def remove(key)
feature = get(key)
return unless persisted?(feature)
feature.remove
end
def flipper
if Gitlab::SafeRequestStore.active?
Gitlab::SafeRequestStore[:flipper] ||= build_flipper_instance

View file

@ -254,6 +254,22 @@ describe Feature do
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 '#targets' do
let(:project) { create(:project) }