diff --git a/app/graphql/types/base_field.rb b/app/graphql/types/base_field.rb index 47caf83eb1c9d49145bc7059cc753c861d222fe9..ce2f184bcb445955dbdaffc2cc660294537e41db 100644 --- a/app/graphql/types/base_field.rb +++ b/app/graphql/types/base_field.rb @@ -65,7 +65,7 @@ def constant_complexity? 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 diff --git a/spec/graphql/features/feature_flag_spec.rb b/spec/graphql/features/feature_flag_spec.rb index 30238cf9cb34690cf4716a4f58bd848bee1a4aa6..e5560fccf894c09c21befa4d101250c862163530 100644 --- a/spec/graphql/features/feature_flag_spec.rb +++ b/spec/graphql/features/feature_flag_spec.rb @@ -28,14 +28,25 @@ 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 diff --git a/spec/graphql/types/base_field_spec.rb b/spec/graphql/types/base_field_spec.rb index 54b59317b55894f590115490c889a55e296b1e97..ebdb3299bc9196b7f4cabe32eb625fe60a3f0016 100644 --- a/spec/graphql/types/base_field_spec.rb +++ b/spec/graphql/types/base_field_spec.rb @@ -130,14 +130,25 @@ def self.complexity_multiplier(args) 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