summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Kalderimis <alex.kalderimis@gmail.com>2019-07-29 15:25:41 -0400
committerAlex Kalderimis <alex.kalderimis@gmail.com>2019-07-30 11:15:52 -0400
commit8738a83390e640059b5c3f20ec13f4c3c48576ae (patch)
treee2250455f47c5102536662aa239d8508c2cf25a7
parentab509c78929d9b5f4e02d013e8911ac9d0a07aad (diff)
downloadgitlab-ce-ce-delete-designs-v2.tar.gz
Improves the graphql_helpers used in GraphQL testsce-delete-designs-v2
This improves the graphql test helpers, failing earlier and more explicitly.
-rw-r--r--spec/support/helpers/graphql_helpers.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/spec/support/helpers/graphql_helpers.rb b/spec/support/helpers/graphql_helpers.rb
index ae1b859ae3f..d86371d70b9 100644
--- a/spec/support/helpers/graphql_helpers.rb
+++ b/spec/support/helpers/graphql_helpers.rb
@@ -3,6 +3,8 @@
module GraphqlHelpers
MutationDefinition = Struct.new(:query, :variables)
+ NoData = Class.new(StandardError)
+
# makes an underscored string look like a fieldname
# "merge_request" => "mergeRequest"
def self.fieldnamerize(underscored_field_name)
@@ -158,8 +160,9 @@ module GraphqlHelpers
post_graphql(mutation.query, current_user: current_user, variables: mutation.variables)
end
+ # Raises an error if no data is found
def graphql_data
- json_response['data']
+ json_response['data'] || (raise NoData, graphql_errors)
end
def graphql_errors
@@ -173,8 +176,9 @@ module GraphqlHelpers
end
end
+ # Raises an error if no response is found
def graphql_mutation_response(mutation_name)
- graphql_data[GraphqlHelpers.fieldnamerize(mutation_name)]
+ graphql_data.fetch(GraphqlHelpers.fieldnamerize(mutation_name))
end
def nested_fields?(field)