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:
Diffstat (limited to 'spec/graphql/types')
-rw-r--r--spec/graphql/types/access_levels/deploy_key_type_spec.rb13
-rw-r--r--spec/graphql/types/access_levels/user_type_spec.rb41
-rw-r--r--spec/graphql/types/alert_management/alert_type_spec.rb1
-rw-r--r--spec/graphql/types/branch_protections/merge_access_level_type_spec.rb2
-rw-r--r--spec/graphql/types/branch_protections/push_access_level_type_spec.rb4
-rw-r--r--spec/graphql/types/branch_rules/branch_protection_type_spec.rb2
-rw-r--r--spec/graphql/types/ci/detailed_status_type_spec.rb2
-rw-r--r--spec/graphql/types/ci/pipeline_trigger_type_spec.rb17
-rw-r--r--spec/graphql/types/ci/runner_manager_type_spec.rb2
-rw-r--r--spec/graphql/types/commit_type_spec.rb10
-rw-r--r--spec/graphql/types/custom_emoji_type_spec.rb13
-rw-r--r--spec/graphql/types/diff_type_spec.rb27
-rw-r--r--spec/graphql/types/group_type_spec.rb9
-rw-r--r--spec/graphql/types/issue_type_enum_spec.rb2
-rw-r--r--spec/graphql/types/issue_type_spec.rb2
-rw-r--r--spec/graphql/types/merge_request_state_enum_spec.rb2
-rw-r--r--spec/graphql/types/namespace/package_settings_type_spec.rb2
-rw-r--r--spec/graphql/types/project_type_spec.rb4
-rw-r--r--spec/graphql/types/projects/branch_rule_type_spec.rb2
-rw-r--r--spec/graphql/types/users/autocompleted_user_type_spec.rb19
-rw-r--r--spec/graphql/types/work_items/linked_item_type_spec.rb13
-rw-r--r--spec/graphql/types/work_items/related_link_type_enum_spec.rb13
-rw-r--r--spec/graphql/types/work_items/widget_interface_spec.rb3
-rw-r--r--spec/graphql/types/work_items/widgets/linked_items_type_spec.rb12
24 files changed, 200 insertions, 17 deletions
diff --git a/spec/graphql/types/access_levels/deploy_key_type_spec.rb b/spec/graphql/types/access_levels/deploy_key_type_spec.rb
new file mode 100644
index 00000000000..02f58ec4c15
--- /dev/null
+++ b/spec/graphql/types/access_levels/deploy_key_type_spec.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe GitlabSchema.types['AccessLevelDeployKey'], feature_category: :source_code_management do
+ subject { described_class }
+
+ let(:fields) { %i[id title expires_at user] }
+
+ specify { is_expected.to require_graphql_authorizations(:read_deploy_key) }
+
+ specify { is_expected.to have_graphql_fields(fields).at_least }
+end
diff --git a/spec/graphql/types/access_levels/user_type_spec.rb b/spec/graphql/types/access_levels/user_type_spec.rb
new file mode 100644
index 00000000000..7a34f70e166
--- /dev/null
+++ b/spec/graphql/types/access_levels/user_type_spec.rb
@@ -0,0 +1,41 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe GitlabSchema.types['AccessLevelUser'], feature_category: :source_code_management do
+ include GraphqlHelpers
+
+ describe 'config' do
+ subject { described_class }
+
+ let(:expected_fields) { %w[id username name publicEmail avatarUrl webUrl webPath] }
+
+ it { is_expected.to require_graphql_authorizations(:read_user) }
+ it { is_expected.to have_graphql_fields(expected_fields).only }
+ end
+
+ describe 'fields' do
+ let(:object) { instance_double(User) }
+ let(:current_user) { instance_double(User) }
+
+ before do
+ allow(described_class).to receive(:authorized?).and_return(true)
+ end
+
+ describe '#name' do
+ it 'calls User#redacted_name(current_user)' do
+ allow(object).to receive(:redacted_name).with(current_user)
+ resolve_field(:name, object, current_user: current_user)
+ expect(object).to have_received(:redacted_name).with(current_user).once
+ end
+ end
+
+ describe '#avatar_url' do
+ it 'calls User#avatar_url(only_path: false)' do
+ allow(object).to receive(:avatar_url).with(only_path: false)
+ resolve_field(:avatar_url, object, current_user: current_user)
+ expect(object).to have_received(:avatar_url).with(only_path: false).once
+ end
+ end
+ end
+end
diff --git a/spec/graphql/types/alert_management/alert_type_spec.rb b/spec/graphql/types/alert_management/alert_type_spec.rb
index 92e8104fc4d..7c7b4cde60b 100644
--- a/spec/graphql/types/alert_management/alert_type_spec.rb
+++ b/spec/graphql/types/alert_management/alert_type_spec.rb
@@ -34,6 +34,7 @@ RSpec.describe GitlabSchema.types['AlertManagementAlert'], feature_category: :in
runbook
todos
details_url
+ metrics_dashboard_url
prometheus_alert
environment
web_url
diff --git a/spec/graphql/types/branch_protections/merge_access_level_type_spec.rb b/spec/graphql/types/branch_protections/merge_access_level_type_spec.rb
index 8cc1005d97e..0586a643196 100644
--- a/spec/graphql/types/branch_protections/merge_access_level_type_spec.rb
+++ b/spec/graphql/types/branch_protections/merge_access_level_type_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe GitlabSchema.types['MergeAccessLevel'] do
+RSpec.describe GitlabSchema.types['MergeAccessLevel'], feature_category: :source_code_management do
subject { described_class }
let(:fields) { %i[access_level access_level_description] }
diff --git a/spec/graphql/types/branch_protections/push_access_level_type_spec.rb b/spec/graphql/types/branch_protections/push_access_level_type_spec.rb
index c78c0bda74c..ec5d42ac720 100644
--- a/spec/graphql/types/branch_protections/push_access_level_type_spec.rb
+++ b/spec/graphql/types/branch_protections/push_access_level_type_spec.rb
@@ -2,10 +2,10 @@
require 'spec_helper'
-RSpec.describe GitlabSchema.types['PushAccessLevel'] do
+RSpec.describe GitlabSchema.types['PushAccessLevel'], feature_category: :source_code_management do
subject { described_class }
- let(:fields) { %i[access_level access_level_description] }
+ let(:fields) { %i[access_level access_level_description deploy_key] }
specify { is_expected.to require_graphql_authorizations(:read_protected_branch) }
diff --git a/spec/graphql/types/branch_rules/branch_protection_type_spec.rb b/spec/graphql/types/branch_rules/branch_protection_type_spec.rb
index bbc92fd8fef..d74c76d3f94 100644
--- a/spec/graphql/types/branch_rules/branch_protection_type_spec.rb
+++ b/spec/graphql/types/branch_rules/branch_protection_type_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe GitlabSchema.types['BranchProtection'] do
+RSpec.describe GitlabSchema.types['BranchProtection'], feature_category: :source_code_management do
subject { described_class }
let(:fields) { %i[merge_access_levels push_access_levels allow_force_push] }
diff --git a/spec/graphql/types/ci/detailed_status_type_spec.rb b/spec/graphql/types/ci/detailed_status_type_spec.rb
index 69fb2bc43c0..81ab1b52552 100644
--- a/spec/graphql/types/ci/detailed_status_type_spec.rb
+++ b/spec/graphql/types/ci/detailed_status_type_spec.rb
@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe Types::Ci::DetailedStatusType do
include GraphqlHelpers
- let_it_be(:stage) { create(:ci_stage, status: :manual) }
+ let_it_be(:stage) { create(:ci_stage, status: :skipped) }
specify { expect(described_class.graphql_name).to eq('DetailedStatus') }
diff --git a/spec/graphql/types/ci/pipeline_trigger_type_spec.rb b/spec/graphql/types/ci/pipeline_trigger_type_spec.rb
new file mode 100644
index 00000000000..2d39118bad8
--- /dev/null
+++ b/spec/graphql/types/ci/pipeline_trigger_type_spec.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe GitlabSchema.types['PipelineTrigger'], feature_category: :continuous_integration do
+ specify do
+ expect(described_class).to have_graphql_fields(%i[
+ can_access_project
+ description
+ has_token_exposed
+ last_used
+ id
+ owner
+ token
+ ]).at_least
+ end
+end
diff --git a/spec/graphql/types/ci/runner_manager_type_spec.rb b/spec/graphql/types/ci/runner_manager_type_spec.rb
index 6f73171cd8f..ff7297b0a0e 100644
--- a/spec/graphql/types/ci/runner_manager_type_spec.rb
+++ b/spec/graphql/types/ci/runner_manager_type_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe GitlabSchema.types['CiRunnerManager'], feature_category: :runner_
it 'contains attributes related to a runner manager' do
expected_fields = %w[
- architecture_name contacted_at created_at executor_name id ip_address platform_name revision
+ architecture_name contacted_at created_at executor_name id ip_address job_execution_status platform_name revision
runner status system_id version
]
diff --git a/spec/graphql/types/commit_type_spec.rb b/spec/graphql/types/commit_type_spec.rb
index 561d165148b..6af5ea04dd2 100644
--- a/spec/graphql/types/commit_type_spec.rb
+++ b/spec/graphql/types/commit_type_spec.rb
@@ -12,8 +12,14 @@ RSpec.describe GitlabSchema.types['Commit'] do
it 'contains attributes related to commit' do
expect(described_class).to have_graphql_fields(
:id, :sha, :short_id, :title, :full_title, :full_title_html, :description, :description_html, :message, :title_html, :authored_date,
- :author_name, :author_email, :author_gravatar, :author, :web_url, :web_path,
- :pipelines, :signature_html, :signature
+ :author_name, :author_email, :author_gravatar, :author, :diffs, :web_url, :web_path,
+ :pipelines, :signature_html, :signature, :committer_name, :committer_email, :committed_date
)
end
+
+ describe 'diffs' do
+ it 'limits field call count' do
+ expect(described_class.fields['diffs'].extensions).to include(a_kind_of(::Gitlab::Graphql::Limit::FieldCallCount))
+ end
+ end
end
diff --git a/spec/graphql/types/custom_emoji_type_spec.rb b/spec/graphql/types/custom_emoji_type_spec.rb
index 7f3c99e4b63..17697321602 100644
--- a/spec/graphql/types/custom_emoji_type_spec.rb
+++ b/spec/graphql/types/custom_emoji_type_spec.rb
@@ -3,9 +3,20 @@
require 'spec_helper'
RSpec.describe GitlabSchema.types['CustomEmoji'] do
+ expected_fields = %w[
+ id
+ name
+ url
+ external
+ created_at
+ user_permissions
+ ]
+
specify { expect(described_class.graphql_name).to eq('CustomEmoji') }
specify { expect(described_class).to require_graphql_authorizations(:read_custom_emoji) }
- specify { expect(described_class).to have_graphql_fields(:id, :name, :url, :external) }
+ specify { expect(described_class).to have_graphql_fields(*expected_fields) }
+
+ specify { expect(described_class).to expose_permissions_using(Types::PermissionTypes::CustomEmoji) }
end
diff --git a/spec/graphql/types/diff_type_spec.rb b/spec/graphql/types/diff_type_spec.rb
new file mode 100644
index 00000000000..04f4ff9feed
--- /dev/null
+++ b/spec/graphql/types/diff_type_spec.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe GitlabSchema.types['Diff'], feature_category: :code_review_workflow do
+ include RepoHelpers
+ include GraphqlHelpers
+
+ specify { expect(described_class.graphql_name).to eq('Diff') }
+
+ it 'contains attributes related to diff' do
+ expect(described_class).to have_graphql_fields(
+ :a_mode, :b_mode, :deleted_file, :diff, :new_file, :new_path, :old_path, :renamed_file
+ )
+ end
+
+ describe '#diff' do
+ subject { resolve_field(:diff, diff, object_type: described_class) }
+
+ let(:merge_request_diff) { create(:merge_request).merge_request_diff }
+ let(:diff) { merge_request_diff.diffs.diffs.first }
+
+ it 'returns the diff of the passed commit' do
+ is_expected.to eq(diff.diff)
+ end
+ end
+end
diff --git a/spec/graphql/types/group_type_spec.rb b/spec/graphql/types/group_type_spec.rb
index 0fbf50fe258..6622551f063 100644
--- a/spec/graphql/types/group_type_spec.rb
+++ b/spec/graphql/types/group_type_spec.rb
@@ -26,7 +26,7 @@ RSpec.describe GitlabSchema.types['Group'] do
dependency_proxy_image_prefix dependency_proxy_image_ttl_policy
shared_runners_setting timelogs organization_state_counts organizations
contact_state_counts contacts work_item_types
- recent_issue_boards ci_variables releases
+ recent_issue_boards ci_variables releases environment_scopes work_items autocomplete_users
]
expect(described_class).to include_graphql_fields(*expected_fields)
@@ -77,6 +77,13 @@ RSpec.describe GitlabSchema.types['Group'] do
it { is_expected.to have_graphql_resolver(Resolvers::GroupReleasesResolver) }
end
+ describe 'work_items field' do
+ subject { described_class.fields['workItems'] }
+
+ it { is_expected.to have_graphql_type(Types::WorkItemType.connection_type) }
+ it { is_expected.to have_graphql_resolver(Resolvers::Namespaces::WorkItemsResolver) }
+ end
+
it_behaves_like 'a GraphQL type with labels' do
let(:labels_resolver_arguments) { [:search_term, :includeAncestorGroups, :includeDescendantGroups, :onlyGroupLabels] }
end
diff --git a/spec/graphql/types/issue_type_enum_spec.rb b/spec/graphql/types/issue_type_enum_spec.rb
index 33a3a9cf8ce..5b1bc9c3d9c 100644
--- a/spec/graphql/types/issue_type_enum_spec.rb
+++ b/spec/graphql/types/issue_type_enum_spec.rb
@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe Types::IssueTypeEnum, feature_category: :team_planning do
specify { expect(described_class.graphql_name).to eq('IssueType') }
- it 'exposes all the existing issue type values except key_result' do
+ it 'exposes all the existing issue type values except epic' do
expect(described_class.values.keys).to match_array(
%w[ISSUE INCIDENT TEST_CASE REQUIREMENT TASK OBJECTIVE KEY_RESULT]
)
diff --git a/spec/graphql/types/issue_type_spec.rb b/spec/graphql/types/issue_type_spec.rb
index 7c4f2a06147..6c4e68fba6b 100644
--- a/spec/graphql/types/issue_type_spec.rb
+++ b/spec/graphql/types/issue_type_spec.rb
@@ -19,7 +19,7 @@ RSpec.describe GitlabSchema.types['Issue'] do
it 'has specific fields' do
fields = %i[id iid title description state reference author assignees updated_by participants labels milestone due_date
confidential hidden discussion_locked upvotes downvotes merge_requests_count 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
+ emails_disabled emails_enabled 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 alert_management_alerts severity current_user_todos moved moved_to
closed_as_duplicate_of create_note_email timelogs project_id customer_relations_contacts escalation_status]
diff --git a/spec/graphql/types/merge_request_state_enum_spec.rb b/spec/graphql/types/merge_request_state_enum_spec.rb
index 6fc5803a5d0..9c286c54e15 100644
--- a/spec/graphql/types/merge_request_state_enum_spec.rb
+++ b/spec/graphql/types/merge_request_state_enum_spec.rb
@@ -8,6 +8,6 @@ RSpec.describe GitlabSchema.types['MergeRequestState'] do
it_behaves_like 'issuable state'
it 'exposes all the existing merge request states' do
- expect(described_class.values.keys).to include('merged')
+ expect(described_class.values.keys).to include('merged', 'opened')
end
end
diff --git a/spec/graphql/types/namespace/package_settings_type_spec.rb b/spec/graphql/types/namespace/package_settings_type_spec.rb
index 40048b7dfa6..d823f2017b6 100644
--- a/spec/graphql/types/namespace/package_settings_type_spec.rb
+++ b/spec/graphql/types/namespace/package_settings_type_spec.rb
@@ -21,6 +21,8 @@ RSpec.describe GitlabSchema.types['PackageSettings'], feature_category: :package
maven_duplicate_exception_regex
generic_duplicates_allowed
generic_duplicate_exception_regex
+ nuget_duplicates_allowed
+ nuget_duplicate_exception_regex
maven_package_requests_forwarding
lock_maven_package_requests_forwarding
npm_package_requests_forwarding
diff --git a/spec/graphql/types/project_type_spec.rb b/spec/graphql/types/project_type_spec.rb
index 262164a0821..cd9a0642ae6 100644
--- a/spec/graphql/types/project_type_spec.rb
+++ b/spec/graphql/types/project_type_spec.rb
@@ -38,7 +38,7 @@ RSpec.describe GitlabSchema.types['Project'] do
ci_template timelogs merge_commit_template squash_commit_template work_item_types
recent_issue_boards ci_config_path_or_default packages_cleanup_policy ci_variables
timelog_categories fork_targets branch_rules ci_config_variables pipeline_schedules languages
- incident_management_timeline_event_tags visible_forks inherited_ci_variables
+ incident_management_timeline_event_tags visible_forks inherited_ci_variables autocomplete_users
]
expect(described_class).to include_graphql_fields(*expected_fields)
@@ -291,7 +291,7 @@ RSpec.describe GitlabSchema.types['Project'] do
let_it_be(:project) { create(:project_empty_repo) }
it 'raises an error' do
- expect(subject['errors'][0]['message']).to eq('UF You must <a target="_blank" rel="noopener noreferrer" ' \
+ expect(subject['errors'][0]['message']).to eq('You must <a target="_blank" rel="noopener noreferrer" ' \
'href="http://localhost/help/user/project/repository/index.md#' \
'add-files-to-a-repository">add at least one file to the ' \
'repository</a> before using Security features.')
diff --git a/spec/graphql/types/projects/branch_rule_type_spec.rb b/spec/graphql/types/projects/branch_rule_type_spec.rb
index 54ea4f6857b..fc7bf4252f1 100644
--- a/spec/graphql/types/projects/branch_rule_type_spec.rb
+++ b/spec/graphql/types/projects/branch_rule_type_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe GitlabSchema.types['BranchRule'] do
+RSpec.describe GitlabSchema.types['BranchRule'], feature_category: :source_code_management do
include GraphqlHelpers
subject { described_class }
diff --git a/spec/graphql/types/users/autocompleted_user_type_spec.rb b/spec/graphql/types/users/autocompleted_user_type_spec.rb
new file mode 100644
index 00000000000..7b7af429765
--- /dev/null
+++ b/spec/graphql/types/users/autocompleted_user_type_spec.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe GitlabSchema.types['AutocompletedUser'], feature_category: :team_planning do
+ it { expect(described_class).to require_graphql_authorizations(:read_user) }
+
+ describe '#merge_request_interaction' do
+ subject { described_class.fields['mergeRequestInteraction'] }
+
+ it 'returns the correct type' do
+ is_expected.to have_graphql_type(Types::UserMergeRequestInteractionType)
+ end
+
+ it 'has the correct arguments' do
+ expect(subject.arguments).to have_key('id')
+ end
+ end
+end
diff --git a/spec/graphql/types/work_items/linked_item_type_spec.rb b/spec/graphql/types/work_items/linked_item_type_spec.rb
new file mode 100644
index 00000000000..7d7fda45ce4
--- /dev/null
+++ b/spec/graphql/types/work_items/linked_item_type_spec.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Types::WorkItems::LinkedItemType, feature_category: :portfolio_management do
+ specify { expect(described_class.graphql_name).to eq('LinkedWorkItemType') }
+
+ it 'exposes the expected fields' do
+ expected_fields = %i[linkCreatedAt linkId linkType linkUpdatedAt workItem]
+
+ expect(described_class).to have_graphql_fields(*expected_fields)
+ end
+end
diff --git a/spec/graphql/types/work_items/related_link_type_enum_spec.rb b/spec/graphql/types/work_items/related_link_type_enum_spec.rb
new file mode 100644
index 00000000000..38c180b58d4
--- /dev/null
+++ b/spec/graphql/types/work_items/related_link_type_enum_spec.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Types::WorkItems::RelatedLinkTypeEnum, feature_category: :portfolio_management do
+ specify { expect(described_class.graphql_name).to eq('WorkItemRelatedLinkType') }
+
+ it 'exposes all the existing access levels' do
+ expected_fields = Gitlab.ee? ? %w[RELATED BLOCKS BLOCKED_BY] : %w[RELATED]
+
+ expect(described_class.values.keys).to match_array(expected_fields)
+ end
+end
diff --git a/spec/graphql/types/work_items/widget_interface_spec.rb b/spec/graphql/types/work_items/widget_interface_spec.rb
index d955ec5023e..645e63033c5 100644
--- a/spec/graphql/types/work_items/widget_interface_spec.rb
+++ b/spec/graphql/types/work_items/widget_interface_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Types::WorkItems::WidgetInterface do
+RSpec.describe Types::WorkItems::WidgetInterface, feature_category: :team_planning do
include GraphqlHelpers
it 'exposes the expected fields' do
@@ -23,6 +23,7 @@ RSpec.describe Types::WorkItems::WidgetInterface do
WorkItems::Widgets::Notifications | Types::WorkItems::Widgets::NotificationsType
WorkItems::Widgets::CurrentUserTodos | Types::WorkItems::Widgets::CurrentUserTodosType
WorkItems::Widgets::AwardEmoji | Types::WorkItems::Widgets::AwardEmojiType
+ WorkItems::Widgets::LinkedItems | Types::WorkItems::Widgets::LinkedItemsType
end
with_them do
diff --git a/spec/graphql/types/work_items/widgets/linked_items_type_spec.rb b/spec/graphql/types/work_items/widgets/linked_items_type_spec.rb
new file mode 100644
index 00000000000..db6f27ecf1f
--- /dev/null
+++ b/spec/graphql/types/work_items/widgets/linked_items_type_spec.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Types::WorkItems::Widgets::LinkedItemsType, feature_category: :portfolio_management do
+ it 'exposes the expected fields' do
+ expected_fields = %i[type linkedItems]
+
+ expect(described_class.graphql_name).to eq('WorkItemWidgetLinkedItems')
+ expect(described_class).to include_graphql_fields(*expected_fields)
+ end
+end