Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2018-06-28 15:24:21 +0300
committerSean McGivern <sean@mcgivern.me.uk>2018-06-28 15:24:21 +0300
commit63c64ab3236a5ddf45a2ca56683d07e4140ea90e (patch)
treec021b7f30858b330e326d64c016fc74e1a40c461 /spec/support
parent3a6f2739f472d74f88ab43f1a9856bf760be5250 (diff)
parent54b56f20b7a70d3e6284c8105eb3d4a568e255b0 (diff)
Merge branch 'bvl-graphql-permissions' into 'master'
expose permissions on types Closes #47695 See merge request gitlab-org/gitlab-ce!20152
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/matchers/graphql_matchers.rb29
-rw-r--r--spec/support/shared_examples/requests/graphql_shared_examples.rb4
2 files changed, 29 insertions, 4 deletions
diff --git a/spec/support/matchers/graphql_matchers.rb b/spec/support/matchers/graphql_matchers.rb
index d23cbaf4beb..be6fa4c71a0 100644
--- a/spec/support/matchers/graphql_matchers.rb
+++ b/spec/support/matchers/graphql_matchers.rb
@@ -7,9 +7,24 @@ RSpec::Matchers.define :require_graphql_authorizations do |*expected|
end
RSpec::Matchers.define :have_graphql_fields do |*expected|
+ def expected_field_names
+ expected.map { |name| GraphqlHelpers.fieldnamerize(name) }
+ end
+
match do |kls|
- field_names = expected.map { |name| GraphqlHelpers.fieldnamerize(name) }
- expect(kls.fields.keys).to contain_exactly(*field_names)
+ expect(kls.fields.keys).to contain_exactly(*expected_field_names)
+ end
+
+ failure_message do |kls|
+ missing = expected_field_names - kls.fields.keys
+ extra = kls.fields.keys - expected_field_names
+
+ message = []
+
+ message << "is missing fields: <#{missing.inspect}>" if missing.any?
+ message << "contained unexpected fields: <#{extra.inspect}>" if extra.any?
+
+ message.join("\n")
end
end
@@ -44,3 +59,13 @@ RSpec::Matchers.define :have_graphql_resolver do |expected|
end
end
end
+
+RSpec::Matchers.define :expose_permissions_using do |expected|
+ match do |type|
+ permission_field = type.fields['userPermissions']
+
+ expect(permission_field).not_to be_nil
+ expect(permission_field.type).to be_non_null
+ expect(permission_field.type.of_type.graphql_name).to eq(expected.graphql_name)
+ end
+end
diff --git a/spec/support/shared_examples/requests/graphql_shared_examples.rb b/spec/support/shared_examples/requests/graphql_shared_examples.rb
index 9b2b74593a5..fe7b7bc306f 100644
--- a/spec/support/shared_examples/requests/graphql_shared_examples.rb
+++ b/spec/support/shared_examples/requests/graphql_shared_examples.rb
@@ -3,8 +3,8 @@ require 'spec_helper'
shared_examples 'a working graphql query' do
include GraphqlHelpers
- it 'is returns a successfull response', :aggregate_failures do
- expect(response).to be_success
+ it 'returns a successful response', :aggregate_failures do
+ expect(response).to have_gitlab_http_status(:success)
expect(graphql_errors['errors']).to be_nil
expect(json_response.keys).to include('data')
end