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>2021-05-05 09:10:38 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-05 09:10:38 +0300
commit78bc17257c53bc100a4a1eb07c0fdf032236068f (patch)
treeb74fed64161ca5c0131c26340ee1393187d4c169 /spec/graphql
parent0fb607f5565c6476c508410914075172ff5899b2 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/graphql')
-rw-r--r--spec/graphql/resolvers/ci/template_resolver_spec.rb33
-rw-r--r--spec/graphql/types/ci/template_type_spec.rb16
-rw-r--r--spec/graphql/types/project_type_spec.rb8
3 files changed, 57 insertions, 0 deletions
diff --git a/spec/graphql/resolvers/ci/template_resolver_spec.rb b/spec/graphql/resolvers/ci/template_resolver_spec.rb
new file mode 100644
index 00000000000..bec25640c7f
--- /dev/null
+++ b/spec/graphql/resolvers/ci/template_resolver_spec.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Resolvers::Ci::TemplateResolver do
+ include GraphqlHelpers
+
+ describe '#resolve' do
+ let(:user) { create(:user) }
+ let(:project) { create(:project) }
+
+ subject(:resolve_subject) { resolve(described_class, obj: project, ctx: { current_user: user }, args: { name: template_name }) }
+
+ context 'when template exists' do
+ let(:template_name) { 'Android' }
+
+ it 'returns the found template' do
+ found_template = resolve_subject
+
+ expect(found_template).to be_an_instance_of(Gitlab::Template::GitlabCiYmlTemplate)
+ expect(found_template.name).to eq('Android')
+ end
+ end
+
+ context 'when template does not exist' do
+ let(:template_name) { 'invalidname' }
+
+ it 'returns nil' do
+ expect(resolve_subject).to eq(nil)
+ end
+ end
+ end
+end
diff --git a/spec/graphql/types/ci/template_type_spec.rb b/spec/graphql/types/ci/template_type_spec.rb
new file mode 100644
index 00000000000..95ac9f97e31
--- /dev/null
+++ b/spec/graphql/types/ci/template_type_spec.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Types::Ci::TemplateType do
+ specify { expect(described_class.graphql_name).to eq('CiTemplate') }
+
+ it 'exposes the expected fields' do
+ expected_fields = %i[
+ name
+ content
+ ]
+
+ expect(described_class).to have_graphql_fields(*expected_fields)
+ end
+end
diff --git a/spec/graphql/types/project_type_spec.rb b/spec/graphql/types/project_type_spec.rb
index f2c4068f048..3ef2fbba002 100644
--- a/spec/graphql/types/project_type_spec.rb
+++ b/spec/graphql/types/project_type_spec.rb
@@ -32,6 +32,7 @@ RSpec.describe GitlabSchema.types['Project'] do
issue_status_counts terraform_states alert_management_integrations
container_repositories container_repositories_count
pipeline_analytics squash_read_only sast_ci_configuration
+ ci_template
]
expect(described_class).to include_graphql_fields(*expected_fields)
@@ -379,4 +380,11 @@ RSpec.describe GitlabSchema.types['Project'] do
it { is_expected.to have_graphql_type(Types::Ci::JobType.connection_type) }
it { is_expected.to have_graphql_arguments(:statuses) }
end
+
+ describe 'ci_template field' do
+ subject { described_class.fields['ciTemplate'] }
+
+ it { is_expected.to have_graphql_type(Types::Ci::TemplateType) }
+ it { is_expected.to have_graphql_arguments(:name) }
+ end
end