diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-26 12:08:47 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-26 12:08:47 +0300 |
commit | 66d4203791a01fdedf668a78818a229ea2c07aad (patch) | |
tree | 374fc9f6c5e709cf6ab48e257e6bfe4a504d6bbb /spec/graphql/types | |
parent | a496f41f60e12a0a5c31482b7594ad547e0ade42 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/graphql/types')
-rw-r--r-- | spec/graphql/types/base_field_spec.rb | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/spec/graphql/types/base_field_spec.rb b/spec/graphql/types/base_field_spec.rb index 1f82f316aa7..9e5f6dd2037 100644 --- a/spec/graphql/types/base_field_spec.rb +++ b/spec/graphql/types/base_field_spec.rb @@ -46,7 +46,15 @@ describe Types::BaseField do expect(field.to_graphql.complexity).to eq 12 end - context 'when field has a resolver proc' do + context 'when field has a resolver' do + context 'when a valid complexity is already set' do + let(:field) { described_class.new(name: 'test', type: GraphQL::STRING_TYPE.connection_type, resolver_class: resolver, complexity: 2, max_page_size: 100, null: true) } + + it 'uses this complexity' do + expect(field.to_graphql.complexity).to eq 2 + end + end + context 'and is a connection' do let(:field) { described_class.new(name: 'test', type: GraphQL::STRING_TYPE.connection_type, resolver_class: resolver, max_page_size: 100, null: true) } @@ -59,6 +67,17 @@ describe Types::BaseField do expect(field.to_graphql.complexity.call({}, { first: 1 }, 2)).to eq 2 expect(field.to_graphql.complexity.call({}, { first: 1, foo: true }, 2)).to eq 4 end + + context 'when graphql_resolver_complexity is disabled' do + before do + stub_feature_flags(graphql_resolver_complexity: false) + end + + it 'sets default field complexity' do + expect(field.to_graphql.complexity.call({}, {}, 2)).to eq 1 + expect(field.to_graphql.complexity.call({}, { first: 50 }, 2)).to eq 1 + end + end end context 'and is not a connection' do |