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:
authorRobert Speicher <rspeicher@gmail.com>2021-01-20 22:34:23 +0300
committerRobert Speicher <rspeicher@gmail.com>2021-01-20 22:34:23 +0300
commit6438df3a1e0fb944485cebf07976160184697d72 (patch)
tree00b09bfd170e77ae9391b1a2f5a93ef6839f2597 /spec/graphql/types
parent42bcd54d971da7ef2854b896a7b34f4ef8601067 (diff)
Add latest changes from gitlab-org/gitlab@13-8-stable-eev13.8.0-rc42
Diffstat (limited to 'spec/graphql/types')
-rw-r--r--spec/graphql/types/admin/analytics/instance_statistics/measurement_type_spec.rb44
-rw-r--r--spec/graphql/types/base_enum_spec.rb70
-rw-r--r--spec/graphql/types/board_type_spec.rb2
-rw-r--r--spec/graphql/types/ci/config/job_restriction_type_spec.rb13
-rw-r--r--spec/graphql/types/ci/config/job_type_spec.rb9
-rw-r--r--spec/graphql/types/ci/job_type_spec.rb1
-rw-r--r--spec/graphql/types/issue_type_spec.rb3
-rw-r--r--spec/graphql/types/merge_request_type_spec.rb14
-rw-r--r--spec/graphql/types/namespace/package_settings_type_spec.rb17
-rw-r--r--spec/graphql/types/notes/note_type_spec.rb1
-rw-r--r--spec/graphql/types/packages/composer/details_type_spec.rb23
-rw-r--r--spec/graphql/types/packages/composer/json_type_spec.rb15
-rw-r--r--spec/graphql/types/packages/composer/metadatum_type_spec.rb15
-rw-r--r--spec/graphql/types/packages/package_type_enum_spec.rb (renamed from spec/graphql/types/package_type_enum_spec.rb)0
-rw-r--r--spec/graphql/types/packages/package_type_spec.rb (renamed from spec/graphql/types/package_type_spec.rb)2
-rw-r--r--spec/graphql/types/packages/tag_type_spec.rb15
-rw-r--r--spec/graphql/types/project_type_spec.rb2
-rw-r--r--spec/graphql/types/projects/service_type_spec.rb2
-rw-r--r--spec/graphql/types/query_type_spec.rb6
-rw-r--r--spec/graphql/types/repository_type_spec.rb2
20 files changed, 240 insertions, 16 deletions
diff --git a/spec/graphql/types/admin/analytics/instance_statistics/measurement_type_spec.rb b/spec/graphql/types/admin/analytics/instance_statistics/measurement_type_spec.rb
index de8143a5466..ffb1a0f30c9 100644
--- a/spec/graphql/types/admin/analytics/instance_statistics/measurement_type_spec.rb
+++ b/spec/graphql/types/admin/analytics/instance_statistics/measurement_type_spec.rb
@@ -8,4 +8,48 @@ RSpec.describe GitlabSchema.types['InstanceStatisticsMeasurement'] do
it { is_expected.to have_graphql_field(:recorded_at) }
it { is_expected.to have_graphql_field(:identifier) }
it { is_expected.to have_graphql_field(:count) }
+
+ describe 'authorization' do
+ let_it_be(:measurement) { create(:instance_statistics_measurement, :project_count) }
+ let(:user) { create(:user) }
+
+ let(:query) do
+ <<~GRAPHQL
+ query instanceStatisticsMeasurements($identifier: MeasurementIdentifier!) {
+ instanceStatisticsMeasurements(identifier: $identifier) {
+ nodes {
+ count
+ identifier
+ }
+ }
+ }
+ GRAPHQL
+ end
+
+ subject do
+ GitlabSchema.execute(
+ query,
+ variables: { identifier: 'PROJECTS' },
+ context: { current_user: user }
+ ).to_h
+ end
+
+ context 'when the user is not admin' do
+ it 'returns no data' do
+ expect(subject.dig('data', 'instanceStatisticsMeasurements')).to be_nil
+ end
+ end
+
+ context 'when user is an admin' do
+ let(:user) { create(:user, :admin) }
+
+ before do
+ stub_feature_flags(user_mode_in_session: false)
+ end
+
+ it 'returns data' do
+ expect(subject.dig('data', 'instanceStatisticsMeasurements', 'nodes')).not_to be_empty
+ end
+ end
+ end
end
diff --git a/spec/graphql/types/base_enum_spec.rb b/spec/graphql/types/base_enum_spec.rb
index b7adcf217f6..744aee40044 100644
--- a/spec/graphql/types/base_enum_spec.rb
+++ b/spec/graphql/types/base_enum_spec.rb
@@ -3,7 +3,75 @@
require 'spec_helper'
RSpec.describe Types::BaseEnum do
- describe '#enum' do
+ describe '.declarative_enum' do
+ let(:use_name) { true }
+ let(:use_description) { true }
+ let(:enum_type) do
+ Class.new(described_class) do
+ graphql_name 'OriginalName'
+ description 'Original description'
+ end
+ end
+
+ let(:enum_module) do
+ Module.new do
+ extend DeclarativeEnum
+
+ name 'Name'
+ description 'Description'
+
+ define do
+ foo value: 0, description: 'description of foo'
+ end
+ end
+ end
+
+ subject(:set_declarative_enum) { enum_type.declarative_enum(enum_module, use_name: use_name, use_description: use_description) }
+
+ describe '#graphql_name' do
+ context 'when the use_name is `true`' do
+ it 'changes the graphql_name' do
+ expect { set_declarative_enum }.to change { enum_type.graphql_name }.from('OriginalName').to('Name')
+ end
+ end
+
+ context 'when the use_name is `false`' do
+ let(:use_name) { false }
+
+ it 'does not change the graphql_name' do
+ expect { set_declarative_enum }.not_to change { enum_type.graphql_name }.from('OriginalName')
+ end
+ end
+ end
+
+ describe '#description' do
+ context 'when the use_description is `true`' do
+ it 'changes the description' do
+ expect { set_declarative_enum }.to change { enum_type.description }.from('Original description').to('Description')
+ end
+ end
+
+ context 'when the use_description is `false`' do
+ let(:use_description) { false }
+
+ it 'does not change the description' do
+ expect { set_declarative_enum }.not_to change { enum_type.description }.from('Original description')
+ end
+ end
+ end
+
+ describe '#values' do
+ it 'sets the values defined by the declarative enum' do
+ set_declarative_enum
+
+ expect(enum_type.values.keys).to eq(['FOO'])
+ expect(enum_type.values.values.map(&:description)).to eq(['description of foo'])
+ expect(enum_type.values.values.map(&:value)).to eq([0])
+ end
+ end
+ end
+
+ describe '.enum' do
let(:enum) do
Class.new(described_class) do
value 'TEST', value: 3
diff --git a/spec/graphql/types/board_type_spec.rb b/spec/graphql/types/board_type_spec.rb
index b02b342390d..5ea87d5f473 100644
--- a/spec/graphql/types/board_type_spec.rb
+++ b/spec/graphql/types/board_type_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe GitlabSchema.types['Board'] do
specify { expect(described_class).to require_graphql_authorizations(:read_board) }
it 'has specific fields' do
- expected_fields = %w[id name]
+ expected_fields = %w[id name web_url web_path]
expect(described_class).to include_graphql_fields(*expected_fields)
end
diff --git a/spec/graphql/types/ci/config/job_restriction_type_spec.rb b/spec/graphql/types/ci/config/job_restriction_type_spec.rb
new file mode 100644
index 00000000000..dd46a38b7c2
--- /dev/null
+++ b/spec/graphql/types/ci/config/job_restriction_type_spec.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Types::Ci::Config::JobRestrictionType do
+ specify { expect(described_class.graphql_name).to eq('CiConfigJobRestriction') }
+
+ it 'exposes the expected fields' do
+ expected_fields = %i[refs]
+
+ expect(described_class).to include_graphql_fields(*expected_fields)
+ end
+end
diff --git a/spec/graphql/types/ci/config/job_type_spec.rb b/spec/graphql/types/ci/config/job_type_spec.rb
index 600d665a84b..de4e167f69c 100644
--- a/spec/graphql/types/ci/config/job_type_spec.rb
+++ b/spec/graphql/types/ci/config/job_type_spec.rb
@@ -7,10 +7,19 @@ RSpec.describe Types::Ci::Config::JobType do
it 'exposes the expected fields' do
expected_fields = %i[
+ afterScript
+ allowFailure
+ beforeScript
+ environment
+ except
+ script
name
+ only
group_name
stage
+ tags
needs
+ when
]
expect(described_class).to have_graphql_fields(*expected_fields)
diff --git a/spec/graphql/types/ci/job_type_spec.rb b/spec/graphql/types/ci/job_type_spec.rb
index 441a719df8c..e277916f5cb 100644
--- a/spec/graphql/types/ci/job_type_spec.rb
+++ b/spec/graphql/types/ci/job_type_spec.rb
@@ -4,6 +4,7 @@ require 'spec_helper'
RSpec.describe Types::Ci::JobType do
specify { expect(described_class.graphql_name).to eq('CiJob') }
+ specify { expect(described_class).to require_graphql_authorizations(:read_commit_status) }
it 'exposes the expected fields' do
expected_fields = %i[
diff --git a/spec/graphql/types/issue_type_spec.rb b/spec/graphql/types/issue_type_spec.rb
index 558fc479af1..21fc530149c 100644
--- a/spec/graphql/types/issue_type_spec.rb
+++ b/spec/graphql/types/issue_type_spec.rb
@@ -17,7 +17,8 @@ RSpec.describe GitlabSchema.types['Issue'] do
fields = %i[id iid title description state reference author assignees updated_by participants labels milestone due_date
confidential discussion_locked upvotes downvotes user_notes_count user_discussions_count web_path web_url relative_position
emails_disabled subscribed time_estimate total_time_spent human_time_estimate human_total_time_spent closed_at created_at updated_at task_completion_status
- design_collection alert_management_alert severity current_user_todos moved moved_to]
+ design_collection alert_management_alert severity current_user_todos moved moved_to
+ create_note_email]
fields.each do |field_name|
expect(described_class).to have_graphql_field(field_name)
diff --git a/spec/graphql/types/merge_request_type_spec.rb b/spec/graphql/types/merge_request_type_spec.rb
index 51e7b4029d5..63d288934e5 100644
--- a/spec/graphql/types/merge_request_type_spec.rb
+++ b/spec/graphql/types/merge_request_type_spec.rb
@@ -25,21 +25,15 @@ RSpec.describe GitlabSchema.types['MergeRequest'] do
merge_ongoing mergeable_discussions_state web_url
source_branch_exists target_branch_exists
upvotes downvotes head_pipeline pipelines task_completion_status
- milestone assignees participants subscribed labels discussion_locked time_estimate
+ milestone assignees reviewers participants subscribed labels discussion_locked time_estimate
total_time_spent reference author merged_at commit_count current_user_todos
conflicts auto_merge_enabled approved_by source_branch_protected
default_merge_commit_message_with_description squash_on_merge available_auto_merge_strategies
- has_ci mergeable commits_without_merge_commits security_auto_fix
+ has_ci mergeable commits_without_merge_commits squash security_auto_fix default_squash_commit_message
+ auto_merge_strategy merge_user
]
- if Gitlab.ee?
- expected_fields << 'approved'
- expected_fields << 'approvals_left'
- expected_fields << 'approvals_required'
- expected_fields << 'merge_trains_count'
- end
-
- expect(described_class).to have_graphql_fields(*expected_fields)
+ expect(described_class).to have_graphql_fields(*expected_fields).at_least
end
describe '#pipelines' do
diff --git a/spec/graphql/types/namespace/package_settings_type_spec.rb b/spec/graphql/types/namespace/package_settings_type_spec.rb
new file mode 100644
index 00000000000..b9592d230ca
--- /dev/null
+++ b/spec/graphql/types/namespace/package_settings_type_spec.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe GitlabSchema.types['PackageSettings'] do
+ specify { expect(described_class.graphql_name).to eq('PackageSettings') }
+
+ specify { expect(described_class.description).to eq('Namespace-level Package Registry settings') }
+
+ specify { expect(described_class).to require_graphql_authorizations(:read_package_settings) }
+
+ describe 'maven_duplicate_exception_regex field' do
+ subject { described_class.fields['mavenDuplicateExceptionRegex'] }
+
+ it { is_expected.to have_graphql_type(Types::UntrustedRegexp) }
+ end
+end
diff --git a/spec/graphql/types/notes/note_type_spec.rb b/spec/graphql/types/notes/note_type_spec.rb
index 180d13d35d2..03ff7828cf5 100644
--- a/spec/graphql/types/notes/note_type_spec.rb
+++ b/spec/graphql/types/notes/note_type_spec.rb
@@ -22,6 +22,7 @@ RSpec.describe GitlabSchema.types['Note'] do
system_note_icon_name
updated_at
user_permissions
+ url
]
expect(described_class).to have_graphql_fields(*expected_fields)
diff --git a/spec/graphql/types/packages/composer/details_type_spec.rb b/spec/graphql/types/packages/composer/details_type_spec.rb
new file mode 100644
index 00000000000..2e4cb965ded
--- /dev/null
+++ b/spec/graphql/types/packages/composer/details_type_spec.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe GitlabSchema.types['PackageComposerDetails'] do
+ it { expect(described_class.graphql_name).to eq('PackageComposerDetails') }
+
+ it 'includes all the package fields' do
+ expected_fields = %w[
+ id name version created_at updated_at package_type tags project pipelines versions
+ ]
+
+ expect(described_class).to include_graphql_fields(*expected_fields)
+ end
+
+ it 'includes composer specific files' do
+ expected_fields = %w[
+ composer_metadatum
+ ]
+
+ expect(described_class).to include_graphql_fields(*expected_fields)
+ end
+end
diff --git a/spec/graphql/types/packages/composer/json_type_spec.rb b/spec/graphql/types/packages/composer/json_type_spec.rb
new file mode 100644
index 00000000000..af5194ffb49
--- /dev/null
+++ b/spec/graphql/types/packages/composer/json_type_spec.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe GitlabSchema.types['PackageComposerJsonType'] do
+ it { expect(described_class.graphql_name).to eq('PackageComposerJsonType') }
+
+ it 'includes composer json files' do
+ expected_fields = %w[
+ name type license version
+ ]
+
+ expect(described_class).to include_graphql_fields(*expected_fields)
+ end
+end
diff --git a/spec/graphql/types/packages/composer/metadatum_type_spec.rb b/spec/graphql/types/packages/composer/metadatum_type_spec.rb
new file mode 100644
index 00000000000..0f47d8f1812
--- /dev/null
+++ b/spec/graphql/types/packages/composer/metadatum_type_spec.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe GitlabSchema.types['PackageComposerMetadatumType'] do
+ it { expect(described_class.graphql_name).to eq('PackageComposerMetadatumType') }
+
+ it 'includes composer metadatum fields' do
+ expected_fields = %w[
+ target_sha composer_json
+ ]
+
+ expect(described_class).to include_graphql_fields(*expected_fields)
+ end
+end
diff --git a/spec/graphql/types/package_type_enum_spec.rb b/spec/graphql/types/packages/package_type_enum_spec.rb
index 407d5786f65..407d5786f65 100644
--- a/spec/graphql/types/package_type_enum_spec.rb
+++ b/spec/graphql/types/packages/package_type_enum_spec.rb
diff --git a/spec/graphql/types/package_type_spec.rb b/spec/graphql/types/packages/package_type_spec.rb
index 22048e7a693..7003a4d4d07 100644
--- a/spec/graphql/types/package_type_spec.rb
+++ b/spec/graphql/types/packages/package_type_spec.rb
@@ -7,7 +7,7 @@ RSpec.describe GitlabSchema.types['Package'] do
it 'includes all the package fields' do
expected_fields = %w[
- id name version created_at updated_at package_type
+ id name version created_at updated_at package_type tags project pipelines versions
]
expect(described_class).to include_graphql_fields(*expected_fields)
diff --git a/spec/graphql/types/packages/tag_type_spec.rb b/spec/graphql/types/packages/tag_type_spec.rb
new file mode 100644
index 00000000000..83b705157d8
--- /dev/null
+++ b/spec/graphql/types/packages/tag_type_spec.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe GitlabSchema.types['PackageTag'] do
+ it { expect(described_class.graphql_name).to eq('PackageTag') }
+
+ it 'includes all the package tag fields' do
+ expected_fields = %w[
+ id name created_at updated_at
+ ]
+
+ expect(described_class).to include_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 b3028e034cc..9d0d7a3918a 100644
--- a/spec/graphql/types/project_type_spec.rb
+++ b/spec/graphql/types/project_type_spec.rb
@@ -31,7 +31,7 @@ RSpec.describe GitlabSchema.types['Project'] do
container_expiration_policy service_desk_enabled service_desk_address
issue_status_counts terraform_states alert_management_integrations
container_repositories container_repositories_count
- pipeline_analytics total_pipeline_duration squash_read_only
+ pipeline_analytics squash_read_only
]
expect(described_class).to include_graphql_fields(*expected_fields)
diff --git a/spec/graphql/types/projects/service_type_spec.rb b/spec/graphql/types/projects/service_type_spec.rb
index f110322ac89..cca7c49e132 100644
--- a/spec/graphql/types/projects/service_type_spec.rb
+++ b/spec/graphql/types/projects/service_type_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe Types::Projects::ServiceType do
it 'resolves the corresponding type for objects' do
expect(described_class.resolve_type(build(:jira_service), {})).to eq(Types::Projects::Services::JiraServiceType)
expect(described_class.resolve_type(build(:service), {})).to eq(Types::Projects::Services::BaseServiceType)
- expect(described_class.resolve_type(build(:alerts_service), {})).to eq(Types::Projects::Services::BaseServiceType)
+ expect(described_class.resolve_type(build(:drone_ci_service), {})).to eq(Types::Projects::Services::BaseServiceType)
expect(described_class.resolve_type(build(:custom_issue_tracker_service), {})).to eq(Types::Projects::Services::BaseServiceType)
end
end
diff --git a/spec/graphql/types/query_type_spec.rb b/spec/graphql/types/query_type_spec.rb
index 7a0b3035607..3e716865e56 100644
--- a/spec/graphql/types/query_type_spec.rb
+++ b/spec/graphql/types/query_type_spec.rb
@@ -94,4 +94,10 @@ RSpec.describe GitlabSchema.types['Query'] do
it { is_expected.to have_graphql_type(Types::ContainerRepositoryDetailsType) }
end
+
+ describe 'package_composer_details field' do
+ subject { described_class.fields['packageComposerDetails'] }
+
+ it { is_expected.to have_graphql_type(Types::Packages::Composer::DetailsType) }
+ end
end
diff --git a/spec/graphql/types/repository_type_spec.rb b/spec/graphql/types/repository_type_spec.rb
index 27780476421..e9199bd286e 100644
--- a/spec/graphql/types/repository_type_spec.rb
+++ b/spec/graphql/types/repository_type_spec.rb
@@ -10,4 +10,6 @@ RSpec.describe GitlabSchema.types['Repository'] do
specify { expect(described_class).to have_graphql_field(:root_ref) }
specify { expect(described_class).to have_graphql_field(:tree) }
+
+ specify { expect(described_class).to have_graphql_field(:exists, calls_gitaly?: true, complexity: 2) }
end