summaryrefslogtreecommitdiff
path: root/spec/graphql/resolvers/projects
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-08 06:09:54 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-08 06:09:54 +0000
commitf6cdec670b9b757fc2225a2c6627ab79765e5b8a (patch)
tree7a1fde030f117b69332d01b22deefd1c81fff458 /spec/graphql/resolvers/projects
parente2ee1eec50aa8df8543d7ecc585ec0ba5ee544ac (diff)
downloadgitlab-ce-f6cdec670b9b757fc2225a2c6627ab79765e5b8a.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/graphql/resolvers/projects')
-rw-r--r--spec/graphql/resolvers/projects/services_resolver_spec.rb72
1 files changed, 72 insertions, 0 deletions
diff --git a/spec/graphql/resolvers/projects/services_resolver_spec.rb b/spec/graphql/resolvers/projects/services_resolver_spec.rb
new file mode 100644
index 00000000000..00045442ea0
--- /dev/null
+++ b/spec/graphql/resolvers/projects/services_resolver_spec.rb
@@ -0,0 +1,72 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Resolvers::Projects::ServicesResolver do
+ include GraphqlHelpers
+
+ describe '#resolve' do
+ let_it_be(:user) { create(:user) }
+
+ context 'when project does not have services' do
+ let_it_be(:project) { create(:project, :private) }
+
+ context 'when user cannot access services' do
+ context 'when anonymous user' do
+ it_behaves_like 'cannot access project services'
+ end
+
+ context 'when user developer' do
+ before do
+ project.add_developer(user)
+ end
+
+ it_behaves_like 'cannot access project services'
+ end
+ end
+
+ context 'when user can read project services' do
+ before do
+ project.add_maintainer(user)
+ end
+
+ it_behaves_like 'no project services'
+ end
+ end
+
+ context 'when project has services' do
+ let_it_be(:project) { create(:project, :private) }
+ let_it_be(:jira_service) { create(:jira_service, project: project) }
+
+ context 'when user cannot access services' do
+ context 'when anonymous user' do
+ it_behaves_like 'cannot access project services'
+ end
+
+ context 'when user developer' do
+ before do
+ project.add_developer(user)
+ end
+
+ it_behaves_like 'cannot access project services'
+ end
+ end
+
+ context 'when user can read project services' do
+ before do
+ project.add_maintainer(user)
+ end
+
+ it 'returns project services' do
+ services = resolve_services
+
+ expect(services.size).to eq 1
+ end
+ end
+ end
+ end
+
+ def resolve_services(args = {}, context = { current_user: user })
+ resolve(described_class, obj: project, args: args, ctx: context)
+ end
+end