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:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-08 09:09:54 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-08 09:09:54 +0300
commitf6cdec670b9b757fc2225a2c6627ab79765e5b8a (patch)
tree7a1fde030f117b69332d01b22deefd1c81fff458 /spec/support
parente2ee1eec50aa8df8543d7ecc585ec0ba5ee544ac (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/helpers/graphql_helpers.rb3
-rw-r--r--spec/support/shared_examples/graphql/projects/services_resolver_shared_examples.rb15
-rw-r--r--spec/support/shared_examples/requests/api/graphql/projects/services_shared_examples.rb21
3 files changed, 38 insertions, 1 deletions
diff --git a/spec/support/helpers/graphql_helpers.rb b/spec/support/helpers/graphql_helpers.rb
index 74582df6cd9..fc543186b08 100644
--- a/spec/support/helpers/graphql_helpers.rb
+++ b/spec/support/helpers/graphql_helpers.rb
@@ -149,7 +149,7 @@ module GraphqlHelpers
FIELDS
end
- def all_graphql_fields_for(class_name, parent_types = Set.new, max_depth: 3)
+ def all_graphql_fields_for(class_name, parent_types = Set.new, max_depth: 3, excluded: [])
# pulling _all_ fields can generate a _huge_ query (like complexity 180,000),
# and significantly increase spec runtime. so limit the depth by default
return if max_depth <= 0
@@ -165,6 +165,7 @@ module GraphqlHelpers
type.fields.map do |name, field|
# We can't guess arguments, so skip fields that require them
next if required_arguments?(field)
+ next if excluded.include?(name)
singular_field_type = field_type(field)
diff --git a/spec/support/shared_examples/graphql/projects/services_resolver_shared_examples.rb b/spec/support/shared_examples/graphql/projects/services_resolver_shared_examples.rb
new file mode 100644
index 00000000000..4bed322564a
--- /dev/null
+++ b/spec/support/shared_examples/graphql/projects/services_resolver_shared_examples.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+shared_examples 'no project services' do
+ it 'returns empty collection' do
+ expect(resolve_services).to eq []
+ end
+end
+
+shared_examples 'cannot access project services' do
+ it 'raises error' do
+ expect do
+ resolve_services
+ end.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable)
+ end
+end
diff --git a/spec/support/shared_examples/requests/api/graphql/projects/services_shared_examples.rb b/spec/support/shared_examples/requests/api/graphql/projects/services_shared_examples.rb
new file mode 100644
index 00000000000..246f1850c3c
--- /dev/null
+++ b/spec/support/shared_examples/requests/api/graphql/projects/services_shared_examples.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+shared_examples 'unauthorized users cannot read services' do
+ before do
+ post_graphql(query, current_user: current_user)
+ end
+
+ context 'when anonymous user' do
+ let(:current_user) { nil }
+
+ it { expect(services).to be nil }
+ end
+
+ context 'when user developer' do
+ before do
+ project.add_developer(current_user)
+ end
+
+ it { expect(services).to be nil }
+ end
+end