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,6 +28,16 @@ RSpec.describe 'Graphql Field feature flags' do ...@@ -28,6 +28,16 @@ RSpec.describe 'Graphql Field feature flags' do
end end
end end
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
context 'skipping YAML check' do
before do
skip_default_enabled_yaml_check
end
it 'returns the value when feature is enabled' do it 'returns the value when feature is enabled' do
expect(subject['item']).to eq('name' => test_object.name) expect(subject['item']).to eq('name' => test_object.name)
end end
...@@ -38,4 +48,5 @@ RSpec.describe 'Graphql Field feature flags' do ...@@ -38,4 +48,5 @@ RSpec.describe 'Graphql Field feature flags' do
expect(subject).to be_nil expect(subject).to be_nil
end end
end end
end
end end
...@@ -130,6 +130,16 @@ RSpec.describe Types::BaseField do ...@@ -130,6 +130,16 @@ RSpec.describe Types::BaseField do
skip_feature_flags_yaml_validation skip_feature_flags_yaml_validation
end end
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
context 'skipping YAML check' do
before do
skip_default_enabled_yaml_check
end
it 'returns false if the feature is not enabled' do it 'returns false if the feature is not enabled' do
stub_feature_flags(flag => false) stub_feature_flags(flag => false)
...@@ -142,6 +152,7 @@ RSpec.describe Types::BaseField do ...@@ -142,6 +152,7 @@ RSpec.describe Types::BaseField do
end end
end end
end end
end
describe '#description' do describe '#description' do
context 'feature flag given' do context 'feature flag given' do
......
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