summaryrefslogtreecommitdiff
path: root/spec/graphql/types
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-10 07:53:40 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-10 07:53:40 +0000
commitcfc792b9ca064990e6540cb742e80529ea669a81 (patch)
tree147cd4256319990cebbc02fe8e4fbbbe06f5720a /spec/graphql/types
parent93c6764dacd4c605027ef1cd367d3aebe420b223 (diff)
downloadgitlab-ce-cfc792b9ca064990e6540cb742e80529ea669a81.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/graphql/types')
-rw-r--r--spec/graphql/types/permission_types/project_spec.rb2
-rw-r--r--spec/graphql/types/permission_types/snippet_spec.rb15
-rw-r--r--spec/graphql/types/permission_types/user_spec.rb15
-rw-r--r--spec/graphql/types/project_type_spec.rb11
-rw-r--r--spec/graphql/types/query_type_spec.rb2
-rw-r--r--spec/graphql/types/snippet_type_spec.rb19
-rw-r--r--spec/graphql/types/user_type_spec.rb17
7 files changed, 78 insertions, 3 deletions
diff --git a/spec/graphql/types/permission_types/project_spec.rb b/spec/graphql/types/permission_types/project_spec.rb
index 6d5a905c128..a3a9872ee1a 100644
--- a/spec/graphql/types/permission_types/project_spec.rb
+++ b/spec/graphql/types/permission_types/project_spec.rb
@@ -8,7 +8,7 @@ describe Types::PermissionTypes::Project do
:change_namespace, :change_visibility_level, :rename_project, :remove_project, :archive_project,
:remove_fork_project, :remove_pages, :read_project, :create_merge_request_in,
:read_wiki, :read_project_member, :create_issue, :upload_file, :read_cycle_analytics,
- :download_code, :download_wiki_code, :fork_project, :create_project_snippet,
+ :download_code, :download_wiki_code, :fork_project, :create_snippet,
:read_commit_status, :request_access, :create_pipeline, :create_pipeline_schedule,
:create_merge_request_from, :create_wiki, :push_code, :create_deployment, :push_to_delete_protected_branch,
:admin_wiki, :admin_project, :update_pages, :admin_remote_mirror, :create_label,
diff --git a/spec/graphql/types/permission_types/snippet_spec.rb b/spec/graphql/types/permission_types/snippet_spec.rb
new file mode 100644
index 00000000000..71843153d43
--- /dev/null
+++ b/spec/graphql/types/permission_types/snippet_spec.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Types::PermissionTypes::Snippet do
+ it 'returns the snippets permissions' do
+ expected_permissions = [
+ :create_note, :award_emoji, :read_snippet, :update_snippet, :admin_snippet
+ ]
+
+ expected_permissions.each do |permission|
+ expect(described_class).to have_graphql_field(permission)
+ end
+ end
+end
diff --git a/spec/graphql/types/permission_types/user_spec.rb b/spec/graphql/types/permission_types/user_spec.rb
new file mode 100644
index 00000000000..1e8201db568
--- /dev/null
+++ b/spec/graphql/types/permission_types/user_spec.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Types::PermissionTypes::User do
+ it 'returns user permissions' do
+ expected_permissions = [
+ :create_snippet
+ ]
+
+ expected_permissions.each do |permission|
+ expect(described_class).to have_graphql_field(permission)
+ end
+ end
+end
diff --git a/spec/graphql/types/project_type_spec.rb b/spec/graphql/types/project_type_spec.rb
index 8a697b1bcae..5d1a5fe1987 100644
--- a/spec/graphql/types/project_type_spec.rb
+++ b/spec/graphql/types/project_type_spec.rb
@@ -22,7 +22,7 @@ describe GitlabSchema.types['Project'] do
only_allow_merge_if_pipeline_succeeds request_access_enabled
only_allow_merge_if_all_discussions_are_resolved printing_merge_request_link_enabled
namespace group statistics repository merge_requests merge_request issues
- issue pipelines removeSourceBranchAfterMerge sentryDetailedError
+ issue pipelines removeSourceBranchAfterMerge sentryDetailedError snippets
]
is_expected.to have_graphql_fields(*expected_fields)
@@ -63,4 +63,13 @@ describe GitlabSchema.types['Project'] do
is_expected.to have_graphql_resolver(Resolvers::MergeRequestsResolver)
end
end
+
+ describe 'snippets field' do
+ subject { described_class.fields['snippets'] }
+
+ it 'returns snippets' do
+ is_expected.to have_graphql_type(Types::SnippetType.connection_type)
+ is_expected.to have_graphql_resolver(Resolvers::Projects::SnippetsResolver)
+ end
+ end
end
diff --git a/spec/graphql/types/query_type_spec.rb b/spec/graphql/types/query_type_spec.rb
index 1365bc0dc14..b2d0ba27d4e 100644
--- a/spec/graphql/types/query_type_spec.rb
+++ b/spec/graphql/types/query_type_spec.rb
@@ -7,7 +7,7 @@ describe GitlabSchema.types['Query'] do
expect(described_class.graphql_name).to eq('Query')
end
- it { is_expected.to have_graphql_fields(:project, :namespace, :group, :echo, :metadata, :current_user) }
+ it { is_expected.to have_graphql_fields(:project, :namespace, :group, :echo, :metadata, :current_user, :snippets) }
describe 'namespace field' do
subject { described_class.fields['namespace'] }
diff --git a/spec/graphql/types/snippet_type_spec.rb b/spec/graphql/types/snippet_type_spec.rb
new file mode 100644
index 00000000000..3c3250a5fa2
--- /dev/null
+++ b/spec/graphql/types/snippet_type_spec.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe GitlabSchema.types['Snippet'] do
+ it 'has the correct fields' do
+ expected_fields = [:id, :title, :project, :author,
+ :file_name, :content, :description,
+ :visibility, :created_at, :updated_at,
+ :web_url, :raw_url, :notes, :discussions,
+ :user_permissions, :description_html]
+
+ is_expected.to have_graphql_fields(*expected_fields)
+ end
+
+ describe 'authorizations' do
+ it { expect(described_class).to require_graphql_authorizations(:read_snippet) }
+ end
+end
diff --git a/spec/graphql/types/user_type_spec.rb b/spec/graphql/types/user_type_spec.rb
index 8134cc13eb4..b9174b9a90b 100644
--- a/spec/graphql/types/user_type_spec.rb
+++ b/spec/graphql/types/user_type_spec.rb
@@ -6,4 +6,21 @@ describe GitlabSchema.types['User'] do
it { expect(described_class.graphql_name).to eq('User') }
it { expect(described_class).to require_graphql_authorizations(:read_user) }
+
+ it 'has the expected fields' do
+ expected_fields = %w[
+ user_permissions snippets name username avatarUrl webUrl todos
+ ]
+
+ is_expected.to have_graphql_fields(*expected_fields)
+ end
+
+ describe 'snippets field' do
+ subject { described_class.fields['snippets'] }
+
+ it 'returns snippets' do
+ is_expected.to have_graphql_type(Types::SnippetType.connection_type)
+ is_expected.to have_graphql_resolver(Resolvers::Users::SnippetsResolver)
+ end
+ end
end