diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-24 18:12:19 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-24 18:12:19 +0300 |
commit | 53ab147992c8e791582f625c80811fdda5ba4d5a (patch) | |
tree | a36867b0d6c6e0bb8fc8f474082b3a3710433bc3 /spec/graphql/types/base_field_spec.rb | |
parent | 263baf70a1f64bb773bfb57d74516a008c2bc7e4 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/graphql/types/base_field_spec.rb')
-rw-r--r-- | spec/graphql/types/base_field_spec.rb | 99 |
1 files changed, 0 insertions, 99 deletions
diff --git a/spec/graphql/types/base_field_spec.rb b/spec/graphql/types/base_field_spec.rb index b85716e4d21..9f8a8717efb 100644 --- a/spec/graphql/types/base_field_spec.rb +++ b/spec/graphql/types/base_field_spec.rb @@ -205,39 +205,6 @@ RSpec.describe Types::BaseField do end end end - - describe '#visible?' do - context 'and has a feature_flag' do - let(:flag) { :test_feature } - let(:field) { described_class.new(name: 'test', type: GraphQL::Types::String, _deprecated_feature_flag: flag, null: false) } - let(:context) { {} } - - before do - skip_feature_flags_yaml_validation - 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 - 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 describe '#resolve' do @@ -251,77 +218,11 @@ RSpec.describe Types::BaseField do end end - describe '#description' do - context 'feature flag given' do - let(:field) { described_class.new(name: 'test', type: GraphQL::Types::String, _deprecated_feature_flag: flag, null: false, description: 'Test description.') } - let(:flag) { :test_flag } - - it 'prepends the description' do - expect(field.description).to start_with 'Test description. Available only when feature flag `test_flag` is enabled.' - end - - context 'falsey feature_flag values' do - using RSpec::Parameterized::TableSyntax - - where(:flag, :feature_value, :default_enabled) do - '' | false | false - '' | true | false - nil | false | true - nil | true | false - end - - with_them do - it 'returns the correct description' do - expect(field.description).to eq('Test description.') - end - end - end - - context 'with different default_enabled values' do - using RSpec::Parameterized::TableSyntax - - where(:feature_value, :default_enabled, :expected_description) do - disabled_ff_description = "Test description. Available only when feature flag `test_flag` is enabled. This flag is disabled by default, because the feature is experimental and is subject to change without notice." - enabled_ff_description = "Test description. Available only when feature flag `test_flag` is enabled. This flag is enabled by default." - - false | false | disabled_ff_description - true | false | disabled_ff_description - false | true | enabled_ff_description - true | true | enabled_ff_description - end - - with_them do - before do - stub_feature_flags("#{flag}": feature_value) - - allow(Feature::Definition).to receive(:has_definition?).with(flag).and_return(true) - allow(Feature::Definition).to receive(:default_enabled?).and_return(default_enabled) - end - - it 'returns the correct availability in the description' do - expect(field.description).to eq expected_description - end - end - end - end - end - include_examples 'Gitlab-style deprecations' do def subject(args = {}) base_args = { name: 'test', type: GraphQL::Types::String, null: true } described_class.new(**base_args.merge(args)) end - - it 'interacts well with the `_deprecated_feature_flag` property' do - field = subject( - deprecated: { milestone: '1.10', reason: 'Deprecation reason' }, - description: 'Field description.', - _deprecated_feature_flag: 'foo_flag' - ) - - expect(field.description).to start_with('Field description. Available only when feature flag `foo_flag` is enabled.') - expect(field.description).to end_with('Deprecated in 1.10: Deprecation reason.') - end end end |