Commit 231887f4 authored by Pedro Pombeiro's avatar Pedro Pombeiro

Use YAML default state in GraphQL feature flags

parent 44a778a9
...@@ -65,7 +65,7 @@ module Types ...@@ -65,7 +65,7 @@ module Types
end end
def visible?(context) 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 super
end end
......
...@@ -28,14 +28,25 @@ RSpec.describe 'Graphql Field feature flags' do ...@@ -28,14 +28,25 @@ RSpec.describe 'Graphql Field feature flags' do
end end
end end
it 'returns the value when feature is enabled' do it 'checks YAML definition for default_enabled' do
expect(subject['item']).to eq('name' => test_object.name) # 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 end
it 'returns nil when the feature is disabled' do context 'skipping YAML check' do
stub_feature_flags(feature_flag => false) 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 end
end end
...@@ -130,14 +130,25 @@ RSpec.describe Types::BaseField do ...@@ -130,14 +130,25 @@ RSpec.describe Types::BaseField do
skip_feature_flags_yaml_validation skip_feature_flags_yaml_validation
end end
it 'returns false if the feature is not enabled' do it 'checks YAML definition for default_enabled' do
stub_feature_flags(flag => false) # 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/)
expect(field.visible?(context)).to eq(false)
end end
it 'returns true if the feature is enabled' do context 'skipping YAML check' do
expect(field.visible?(context)).to eq(true) 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 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