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>2023-08-18 13:50:51 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-08-18 13:50:51 +0300
commitdb384e6b19af03b4c3c82a5760d83a3fd79f7982 (patch)
tree34beaef37df5f47ccbcf5729d7583aae093cffa0 /spec/graphql
parent54fd7b1bad233e3944434da91d257fa7f63c3996 (diff)
Add latest changes from gitlab-org/gitlab@16-3-stable-eev16.3.0-rc42
Diffstat (limited to 'spec/graphql')
-rw-r--r--spec/graphql/mutations/issues/update_spec.rb13
-rw-r--r--spec/graphql/mutations/merge_requests/update_spec.rb14
-rw-r--r--spec/graphql/mutations/namespace/package_settings/update_spec.rb18
-rw-r--r--spec/graphql/mutations/work_items/linked_items/base_spec.rb17
-rw-r--r--spec/graphql/resolvers/group_labels_resolver_spec.rb4
-rw-r--r--spec/graphql/resolvers/labels_resolver_spec.rb4
-rw-r--r--spec/graphql/resolvers/metrics/dashboards/annotation_resolver_spec.rb37
-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
31 files changed, 269 insertions, 55 deletions
diff --git a/spec/graphql/mutations/issues/update_spec.rb b/spec/graphql/mutations/issues/update_spec.rb
index ac82037b7e2..622ccb86b2e 100644
--- a/spec/graphql/mutations/issues/update_spec.rb
+++ b/spec/graphql/mutations/issues/update_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Mutations::Issues::Update do
+RSpec.describe Mutations::Issues::Update, feature_category: :team_planning do
let_it_be(:project) { create(:project) }
let_it_be(:user) { create(:user) }
let_it_be(:project_label) { create(:label, project: project) }
@@ -177,6 +177,17 @@ RSpec.describe Mutations::Issues::Update do
end
end
+ context 'when timeEstimate is negative' do
+ let(:time_estimate) { '-1h' }
+
+ it 'raises an argument error and changes are not applied' do
+ expect { mutation.ready?(time_estimate: time_estimate) }
+ .to raise_error(Gitlab::Graphql::Errors::ArgumentError,
+ 'timeEstimate must be greater than or equal to zero. Remember that every new timeEstimate overwrites the previous value.')
+ expect { subject }.not_to change { issue.time_estimate }
+ end
+ end
+
context 'when timeEstimate is 0' do
let(:time_estimate) { '0' }
diff --git a/spec/graphql/mutations/merge_requests/update_spec.rb b/spec/graphql/mutations/merge_requests/update_spec.rb
index 8a10f6cadd0..6ced71c5f4c 100644
--- a/spec/graphql/mutations/merge_requests/update_spec.rb
+++ b/spec/graphql/mutations/merge_requests/update_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Mutations::MergeRequests::Update do
+RSpec.describe Mutations::MergeRequests::Update, feature_category: :team_planning do
let(:merge_request) { create(:merge_request) }
let(:user) { create(:user) }
@@ -59,6 +59,18 @@ RSpec.describe Mutations::MergeRequests::Update do
end
end
+ context 'when timeEstimate is negative' do
+ let(:time_estimate) { '-1h' }
+
+ it 'raises an argument error and changes are not applied' do
+ expect { mutation.ready?(time_estimate: time_estimate) }
+ .to raise_error(Gitlab::Graphql::Errors::ArgumentError,
+ 'timeEstimate must be greater than or equal to zero. ' \
+ 'Remember that every new timeEstimate overwrites the previous value.')
+ expect { subject }.not_to change { merge_request.time_estimate }
+ end
+ end
+
context 'when timeEstimate is 0' do
let(:time_estimate) { '0' }
diff --git a/spec/graphql/mutations/namespace/package_settings/update_spec.rb b/spec/graphql/mutations/namespace/package_settings/update_spec.rb
index 576f514183f..b7f9eac3755 100644
--- a/spec/graphql/mutations/namespace/package_settings/update_spec.rb
+++ b/spec/graphql/mutations/namespace/package_settings/update_spec.rb
@@ -31,6 +31,8 @@ RSpec.describe Mutations::Namespace::PackageSettings::Update, feature_category:
maven_duplicate_exception_regex: 'SNAPSHOT',
generic_duplicates_allowed: true,
generic_duplicate_exception_regex: 'foo',
+ nuget_duplicates_allowed: true,
+ nuget_duplicate_exception_regex: 'foo',
maven_package_requests_forwarding: nil,
lock_maven_package_requests_forwarding: false,
npm_package_requests_forwarding: nil,
@@ -42,6 +44,8 @@ RSpec.describe Mutations::Namespace::PackageSettings::Update, feature_category:
maven_duplicate_exception_regex: 'RELEASE',
generic_duplicates_allowed: false,
generic_duplicate_exception_regex: 'bar',
+ nuget_duplicates_allowed: false,
+ nuget_duplicate_exception_regex: 'bar',
maven_package_requests_forwarding: true,
lock_maven_package_requests_forwarding: true,
npm_package_requests_forwarding: true,
@@ -69,6 +73,18 @@ RSpec.describe Mutations::Namespace::PackageSettings::Update, feature_category:
)
end
end
+
+ context 'when nuget_duplicates_option FF is disabled' do
+ let_it_be(:params) { { namespace_path: namespace.full_path, nuget_duplicates_allowed: false } }
+
+ before do
+ stub_feature_flags(nuget_duplicates_option: false)
+ end
+
+ it 'raises an error' do
+ expect { subject }.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable, /feature flag is disabled/)
+ end
+ end
end
RSpec.shared_examples 'denying access to namespace package setting' do
@@ -95,6 +111,8 @@ RSpec.describe Mutations::Namespace::PackageSettings::Update, feature_category:
maven_duplicate_exception_regex: 'RELEASE',
generic_duplicates_allowed: false,
generic_duplicate_exception_regex: 'bar',
+ nuget_duplicates_allowed: false,
+ nuget_duplicate_exception_regex: 'bar',
maven_package_requests_forwarding: true,
lock_maven_package_requests_forwarding: true,
npm_package_requests_forwarding: true,
diff --git a/spec/graphql/mutations/work_items/linked_items/base_spec.rb b/spec/graphql/mutations/work_items/linked_items/base_spec.rb
new file mode 100644
index 00000000000..7061c37abd3
--- /dev/null
+++ b/spec/graphql/mutations/work_items/linked_items/base_spec.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Mutations::WorkItems::LinkedItems::Base, feature_category: :groups_and_projects do
+ include GraphqlHelpers
+
+ let_it_be(:user) { create(:user) }
+ let_it_be(:project) { create(:project).tap { |group| group.add_maintainer(user) } }
+ let_it_be(:work_item) { create(:work_item, project: project) }
+
+ it 'raises a NotImplementedError error if the update_links method is called on the base class' do
+ mutation = described_class.new(context: { current_user: user }, object: nil, field: nil)
+
+ expect { mutation.resolve(id: work_item.to_gid) }.to raise_error(NotImplementedError)
+ end
+end
diff --git a/spec/graphql/resolvers/group_labels_resolver_spec.rb b/spec/graphql/resolvers/group_labels_resolver_spec.rb
index 341448d7add..08e17cedfcc 100644
--- a/spec/graphql/resolvers/group_labels_resolver_spec.rb
+++ b/spec/graphql/resolvers/group_labels_resolver_spec.rb
@@ -65,7 +65,7 @@ RSpec.describe Resolvers::GroupLabelsResolver do
end
it 'prevents N+1 queries' do
- control = Gitlab::WithRequestStore.with_request_store do
+ control = Gitlab::SafeRequestStore.ensure_request_store do
ActiveRecord::QueryRecorder.new { resolve_labels(group, params).to_a }
end
@@ -75,7 +75,7 @@ RSpec.describe Resolvers::GroupLabelsResolver do
create(:group_label, group: another_subgroup, name: 'another group feature')
expect do
- Gitlab::WithRequestStore.with_request_store do
+ Gitlab::SafeRequestStore.ensure_request_store do
resolve_labels(group, params).to_a
end
end.not_to exceed_query_limit(control.count)
diff --git a/spec/graphql/resolvers/labels_resolver_spec.rb b/spec/graphql/resolvers/labels_resolver_spec.rb
index 8196315dd7c..16cf2e73736 100644
--- a/spec/graphql/resolvers/labels_resolver_spec.rb
+++ b/spec/graphql/resolvers/labels_resolver_spec.rb
@@ -65,7 +65,7 @@ RSpec.describe Resolvers::LabelsResolver do
end
it 'prevents N+1 queries' do
- control = Gitlab::WithRequestStore.with_request_store do
+ control = Gitlab::SafeRequestStore.ensure_request_store do
ActiveRecord::QueryRecorder.new { resolve_labels(project, params).to_a }
end
@@ -75,7 +75,7 @@ RSpec.describe Resolvers::LabelsResolver do
create(:group_label, group: another_subgroup, name: 'another group feature')
expect do
- Gitlab::WithRequestStore.with_request_store do
+ Gitlab::SafeRequestStore.ensure_request_store do
resolve_labels(project, params).to_a
end
end.not_to exceed_query_limit(control.count)
diff --git a/spec/graphql/resolvers/metrics/dashboards/annotation_resolver_spec.rb b/spec/graphql/resolvers/metrics/dashboards/annotation_resolver_spec.rb
index 2ca194d519c..75e0a816086 100644
--- a/spec/graphql/resolvers/metrics/dashboards/annotation_resolver_spec.rb
+++ b/spec/graphql/resolvers/metrics/dashboards/annotation_resolver_spec.rb
@@ -7,13 +7,12 @@ RSpec.describe Resolvers::Metrics::Dashboards::AnnotationResolver, feature_categ
describe '#resolve' do
context 'user with developer access' do
- subject(:resolve_annotations) { resolve(described_class, obj: dashboard, args: args, ctx: { current_user: current_user }) }
+ subject(:resolve_annotations) { resolve(described_class, obj: nil, args: args, ctx: { current_user: current_user }) }
let_it_be(:current_user) { create(:user) }
let_it_be(:environment) { create(:environment) }
let_it_be(:path) { 'config/prometheus/common_metrics.yml' }
- let(:dashboard) { PerformanceMonitoring::PrometheusDashboard.new(path: path, environment: environment) }
let(:args) do
{
from: 10.minutes.ago,
@@ -30,36 +29,6 @@ RSpec.describe Resolvers::Metrics::Dashboards::AnnotationResolver, feature_categ
end
context 'with annotation records' do
- let_it_be(:annotation_1) { create(:metrics_dashboard_annotation, environment: environment, starting_at: 9.minutes.ago, dashboard_path: path) }
-
- it 'loads annotations with usage of finder class', :aggregate_failures do
- expect_next_instance_of(::Metrics::Dashboards::AnnotationsFinder, dashboard: dashboard, params: args) do |finder|
- expect(finder).to receive(:execute).and_return [annotation_1]
- end
-
- expect(resolve_annotations).to eql [annotation_1]
- end
-
- context 'dashboard is missing' do
- let(:dashboard) { nil }
-
- it 'returns empty array', :aggregate_failures do
- expect(::Metrics::Dashboards::AnnotationsFinder).not_to receive(:new)
-
- expect(resolve_annotations).to be_empty
- end
- end
-
- context 'there are no annotations records' do
- it 'returns empty array' do
- allow_next_instance_of(::Metrics::Dashboards::AnnotationsFinder) do |finder|
- allow(finder).to receive(:execute).and_return []
- end
-
- expect(resolve_annotations).to be_empty
- end
- end
-
context 'when metrics dashboard feature is unavailable' do
before do
stub_feature_flags(remove_monitor_metrics: true)
@@ -69,6 +38,10 @@ RSpec.describe Resolvers::Metrics::Dashboards::AnnotationResolver, feature_categ
expect(resolve_annotations).to be_nil
end
end
+
+ it 'returns [] all the time' do
+ expect(resolve_annotations).to be_empty
+ end
end
end
end
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