diff options
author | charlieablett <cablett@gitlab.com> | 2019-05-24 09:29:19 +1200 |
---|---|---|
committer | charlieablett <cablett@gitlab.com> | 2019-05-30 18:27:42 +1200 |
commit | 5f0c230a18b677bd4ec6a4a54085775b0c69a498 (patch) | |
tree | 6dcd917429f27497669406429ee8192507fcb39b /spec/requests | |
parent | d0e32c2cd33476c5ee7f835d14b97068adeb805d (diff) | |
download | gitlab-ce-5f0c230a18b677bd4ec6a4a54085775b0c69a498.tar.gz |
Move complexity/depth to `final_value`
Tidy tests according to reviewer comments.
Move complexity and depth calls from `initial_value` to `final_value`
Log variables as json
Diffstat (limited to 'spec/requests')
-rw-r--r-- | spec/requests/api/graphql_spec.rb | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/spec/requests/api/graphql_spec.rb b/spec/requests/api/graphql_spec.rb index ebf223127b5..abc24fc0fe8 100644 --- a/spec/requests/api/graphql_spec.rb +++ b/spec/requests/api/graphql_spec.rb @@ -17,31 +17,32 @@ describe 'GraphQL' do end context 'logging' do + shared_examples 'logging a graphql query' do + let(:expected_params) do + { query_string: query, variables: variables.to_json, duration: anything, depth: 1, complexity: 1 } + end + + it 'logs a query with the expected params' do + post_graphql(query, variables: variables) + end + end + before do - expect(Gitlab::GraphqlLogger).to receive(:info).with(expected) + expect(Gitlab::GraphqlLogger).to receive(:info).with(expected_params).once end context 'with no variables' do - let(:expected) do - { query_string: query, variables: {}, duration: anything, depth: 1, complexity: 1 } - end + let(:variables) { {} } - it 'logs the query' do - post_graphql(query) - end + it_behaves_like 'logging a graphql query' end context 'with variables' do - let!(:variables) do + let(:variables) do { "foo" => "bar" } end - let(:expected) do - { query_string: query, variables: variables, duration: anything, depth: 1, complexity: 1 } - end - it 'logs the query' do - post_graphql(query, variables: variables) - end + it_behaves_like 'logging a graphql query' end end |