diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-12 18:09:19 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-12 18:09:19 +0300 |
commit | d9b3f39acad88d81eb7a75627c4325651fb7ff13 (patch) | |
tree | 9a10f44168d0d401c15b664c17e8a353674203b5 /spec/graphql | |
parent | f81141c25d0dd79de8c07559bf268cb6e0d287d3 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/graphql')
-rw-r--r-- | spec/graphql/features/feature_flag_spec.rb | 21 | ||||
-rw-r--r-- | spec/graphql/types/base_field_spec.rb | 23 |
2 files changed, 33 insertions, 11 deletions
diff --git a/spec/graphql/features/feature_flag_spec.rb b/spec/graphql/features/feature_flag_spec.rb index 30238cf9cb3..e5560fccf89 100644 --- a/spec/graphql/features/feature_flag_spec.rb +++ b/spec/graphql/features/feature_flag_spec.rb @@ -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 diff --git a/spec/graphql/types/base_field_spec.rb b/spec/graphql/types/base_field_spec.rb index 54b59317b55..ebdb3299bc9 100644 --- a/spec/graphql/types/base_field_spec.rb +++ b/spec/graphql/types/base_field_spec.rb @@ -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 |