summaryrefslogtreecommitdiff
path: root/spec/graphql/types/base_field_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-09-19 01:45:44 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-09-19 01:45:44 +0000
commit85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch)
tree9160f299afd8c80c038f08e1545be119f5e3f1e1 /spec/graphql/types/base_field_spec.rb
parent15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff)
downloadgitlab-ce-85dc423f7090da0a52c73eb66faf22ddb20efff9.tar.gz
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'spec/graphql/types/base_field_spec.rb')
-rw-r--r--spec/graphql/types/base_field_spec.rb59
1 files changed, 6 insertions, 53 deletions
diff --git a/spec/graphql/types/base_field_spec.rb b/spec/graphql/types/base_field_spec.rb
index 73bb54e7ad0..bcfbd7f2480 100644
--- a/spec/graphql/types/base_field_spec.rb
+++ b/spec/graphql/types/base_field_spec.rb
@@ -167,70 +167,23 @@ RSpec.describe Types::BaseField do
end
end
- describe '`deprecated` property' do
- def test_field(args = {})
+ include_examples 'Gitlab-style deprecations' do
+ def subject(args = {})
base_args = { name: 'test', type: GraphQL::STRING_TYPE, null: true }
described_class.new(**base_args.merge(args))
end
- describe 'validations' do
- it 'raises an informative error if `deprecation_reason` is used' do
- expect { test_field(deprecation_reason: 'foo') }.to raise_error(
- ArgumentError,
- 'Use `deprecated` property instead of `deprecation_reason`. ' \
- 'See https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#deprecating-fields'
- )
- end
-
- it 'raises an error if a required property is missing', :aggregate_failures do
- expect { test_field(deprecated: { milestone: '1.10' }) }.to raise_error(
- ArgumentError,
- 'Please provide a `reason` within `deprecated`'
- )
- expect { test_field(deprecated: { reason: 'Deprecation reason' }) }.to raise_error(
- ArgumentError,
- 'Please provide a `milestone` within `deprecated`'
- )
- end
-
- it 'raises an error if milestone is not a String', :aggregate_failures do
- expect { test_field(deprecated: { milestone: 1.10, reason: 'Deprecation reason' }) }.to raise_error(
- ArgumentError,
- '`milestone` must be a `String`'
- )
- end
- end
-
- it 'adds a formatted `deprecated_reason` to the field' do
- field = test_field(deprecated: { milestone: '1.10', reason: 'Deprecation reason' })
-
- expect(field.deprecation_reason).to eq('Deprecation reason. Deprecated in 1.10')
- end
-
- it 'appends to the description if given' do
- field = test_field(
- deprecated: { milestone: '1.10', reason: 'Deprecation reason' },
- description: 'Field description'
- )
-
- expect(field.description).to eq('Field description. Deprecated in 1.10: Deprecation reason')
- end
-
- it 'does not append to the description if it is absent' do
- field = test_field(deprecated: { milestone: '1.10', reason: 'Deprecation reason' })
-
- expect(field.description).to be_nil
- end
-
it 'interacts well with the `feature_flag` property' do
- field = test_field(
+ field = subject(
deprecated: { milestone: '1.10', reason: 'Deprecation reason' },
description: 'Field description',
feature_flag: 'foo_flag'
)
- expect(field.description).to eq('Field description. Available only when feature flag `foo_flag` is enabled. Deprecated in 1.10: Deprecation reason')
+ expectation = 'Field description. Available only when feature flag `foo_flag` is enabled. Deprecated in 1.10: Deprecation reason'
+
+ expect(field.description).to eq(expectation)
end
end
end