diff options
author | charlieablett <cablett@gitlab.com> | 2019-07-02 17:32:44 +1200 |
---|---|---|
committer | charlieablett <cablett@gitlab.com> | 2019-07-05 10:18:50 +1200 |
commit | 675c9b9f6bec35f1e6988a42c4fa6a6f8331d14f (patch) | |
tree | c96af65aa258cb557e7d714c7408eec037525fdf /spec/graphql | |
parent | cf1b0d10bcdde69f05695a2e9a0d380c6badb6d1 (diff) | |
download | gitlab-ce-675c9b9f6bec35f1e6988a42c4fa6a6f8331d14f.tar.gz |
Address reviewer comments58409-increase-graphql-complexity-for-fields-that-make-gitaly-calls
- Remove Gitaly call check for fields that have a constant complexity
declared
- Add associated test
Diffstat (limited to 'spec/graphql')
-rw-r--r-- | spec/graphql/types/base_field_spec.rb | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/spec/graphql/types/base_field_spec.rb b/spec/graphql/types/base_field_spec.rb index 10913e530cf..77ef8933717 100644 --- a/spec/graphql/types/base_field_spec.rb +++ b/spec/graphql/types/base_field_spec.rb @@ -96,10 +96,19 @@ describe Types::BaseField do expect(field.base_complexity).to eq Types::BaseField::DEFAULT_COMPLEXITY end - it 'is overridden by declared complexity value' do - field = described_class.new(name: 'test', type: GraphQL::STRING_TYPE, null: true, calls_gitaly: true, complexity: 12) + context 'with declared constant complexity value' do + it 'has complexity set to that constant' do + field = described_class.new(name: 'test', type: GraphQL::STRING_TYPE, null: true, complexity: 12) - expect(field.to_graphql.complexity).to eq 12 + expect(field.to_graphql.complexity).to eq 12 + end + + it 'does not raise an error even with Gitaly calls' do + allow(Gitlab::GitalyClient).to receive(:get_request_count).and_return([0, 1]) + field = described_class.new(name: 'test', type: GraphQL::STRING_TYPE, null: true, complexity: 12) + + expect(field.to_graphql.complexity).to eq 12 + end end end end |