Commit cfb23600 authored by Alex Kalderimis's avatar Alex Kalderimis

Merge branch 'pedropombeiro/335815/graphql-use-default_enabled-yaml' into 'master'

Use YAML default state in GraphQL feature flags

See merge request gitlab-org/gitlab!65952
parents 5f711ce0 231887f4
......@@ -65,7 +65,7 @@ module Types
end
def visible?(context)
return false if feature_flag.present? && !Feature.enabled?(feature_flag)
return false if feature_flag.present? && !Feature.enabled?(feature_flag, default_enabled: :yaml)
super
end
......
......@@ -28,14 +28,25 @@ RSpec.describe 'Graphql Field feature flags' do
end
end
it 'returns the value when feature is enabled' do
expect(subject['item']).to eq('name' => test_object.name)
it 'checks YAML definition for default_enabled' do
# Exception is indicative of a check for YAML definition
expect { subject }.to raise_error(Feature::InvalidFeatureFlagError, /The feature flag YAML definition for '#{feature_flag}' does not exist/)
end
it 'returns nil when the feature is disabled' do
stub_feature_flags(feature_flag => false)
context 'skipping YAML check' do
before do
skip_default_enabled_yaml_check
end
it 'returns the value when feature is enabled' do
expect(subject['item']).to eq('name' => test_object.name)
end
expect(subject).to be_nil
it 'returns nil when the feature is disabled' do
stub_feature_flags(feature_flag => false)
expect(subject).to be_nil
end
end
end
end
......@@ -130,14 +130,25 @@ RSpec.describe Types::BaseField do
skip_feature_flags_yaml_validation
end
it 'returns false if the feature is not enabled' do
stub_feature_flags(flag => false)
expect(field.visible?(context)).to eq(false)
it 'checks YAML definition for default_enabled' do
# Exception is indicative of a check for YAML definition
expect { field.visible?(context) }.to raise_error(Feature::InvalidFeatureFlagError, /The feature flag YAML definition for '#{flag}' does not exist/)
end
it 'returns true if the feature is enabled' do
expect(field.visible?(context)).to eq(true)
context 'skipping YAML check' do
before do
skip_default_enabled_yaml_check
end
it 'returns false if the feature is not enabled' do
stub_feature_flags(flag => false)
expect(field.visible?(context)).to eq(false)
end
it 'returns true if the feature is enabled' do
expect(field.visible?(context)).to eq(true)
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