diff options
author | charlieablett <cablett@gitlab.com> | 2019-06-28 04:24:47 +0300 |
---|---|---|
committer | charlieablett <cablett@gitlab.com> | 2019-07-03 13:53:13 +0300 |
commit | cf1b0d10bcdde69f05695a2e9a0d380c6badb6d1 (patch) | |
tree | 9bcc0d99dc22a2f4fa2601f1b904c7a418766616 /spec/graphql | |
parent | a11fe5de4408595cc8b2b091cbbb76e423c98f34 (diff) |
Address reviewer comments
- Add 1 for all fields that call Gitaly (with resolvers or without)
- Clarify comment regarding Gitaly call alert
- Expose predicate `calls_gitaly?` instead of ivar
Diffstat (limited to 'spec/graphql')
-rw-r--r-- | spec/graphql/types/base_field_spec.rb | 27 |
1 files changed, 4 insertions, 23 deletions
diff --git a/spec/graphql/types/base_field_spec.rb b/spec/graphql/types/base_field_spec.rb index 0be83ea60c4..10913e530cf 100644 --- a/spec/graphql/types/base_field_spec.rb +++ b/spec/graphql/types/base_field_spec.rb @@ -74,9 +74,11 @@ describe Types::BaseField do context 'calls_gitaly' do context 'for fields with a resolver' do it 'adds 1 if true' do - field = described_class.new(name: 'test', type: GraphQL::STRING_TYPE, null: true, calls_gitaly: true) + with_gitaly_field = described_class.new(name: 'test', type: GraphQL::STRING_TYPE, resolver_class: resolver, null: true, calls_gitaly: true) + without_gitaly_field = described_class.new(name: 'test', type: GraphQL::STRING_TYPE, resolver_class: resolver, null: true) + base_result = without_gitaly_field.to_graphql.complexity.call({}, {}, 2) - expect(field.to_graphql.complexity).to eq 2 + expect(with_gitaly_field.to_graphql.complexity.call({}, {}, 2)).to eq base_result + 1 end end @@ -100,26 +102,5 @@ describe Types::BaseField do expect(field.to_graphql.complexity).to eq 12 end end - - describe '#calls_gitaly_check' do - let(:gitaly_field) { described_class.new(name: 'test', type: GraphQL::STRING_TYPE, null: true, calls_gitaly: true) } - let(:no_gitaly_field) { described_class.new(name: 'test', type: GraphQL::STRING_TYPE, null: true, calls_gitaly: false) } - - context 'if there are no Gitaly calls' do - it 'does not raise an error if calls_gitaly is false' do - expect { no_gitaly_field.send(:calls_gitaly_check, 0) }.not_to raise_error - end - end - - context 'if there is at least 1 Gitaly call' do - it 'does not raise an error if calls_gitaly is true' do - expect { gitaly_field.send(:calls_gitaly_check, 1) }.not_to raise_error - end - - it 'raises an error if calls_gitaly: is false or not defined' do - expect { no_gitaly_field.send(:calls_gitaly_check, 1) }.to raise_error(/please add `calls_gitaly: true`/) - end - end - end end end |