Commit 89435a2b authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'ajk-rubcop-violations-MAR' into 'master'

Fix TODO-ed rubocop violations

See merge request gitlab-org/gitlab!56702
parents 9bbece77 f19aa7a9
...@@ -29,11 +29,9 @@ module Mutations ...@@ -29,11 +29,9 @@ module Mutations
end end
def ready?(**args) def ready?(**args)
if Gitlab::Database.read_only? raise_resource_not_available_error! ERROR_MESSAGE if Gitlab::Database.read_only?
raise_resource_not_available_error! ERROR_MESSAGE
else true
true
end
end end
def load_application_object(argument, lookup_as_type, id, context) def load_application_object(argument, lookup_as_type, id, context)
......
...@@ -7,6 +7,10 @@ module Resolvers ...@@ -7,6 +7,10 @@ module Resolvers
include ResolvesProject include ResolvesProject
type Types::Ci::Config::ConfigType, null: true type Types::Ci::Config::ConfigType, null: true
description <<~MD
Linted and processed contents of a CI config.
Should not be requested more than once per request.
MD
authorize :read_pipeline authorize :read_pipeline
...@@ -55,7 +59,7 @@ module Resolvers ...@@ -55,7 +59,7 @@ module Resolvers
name: job[:name], name: job[:name],
stage: job[:stage], stage: job[:stage],
group_name: CommitStatus.new(name: job[:name]).group_name, group_name: CommitStatus.new(name: job[:name]).group_name,
needs: job.dig(:needs) || [], needs: job[:needs] || [],
allow_failure: job[:allow_failure], allow_failure: job[:allow_failure],
before_script: job[:before_script], before_script: job[:before_script],
script: job[:script], script: job[:script],
......
...@@ -3,24 +3,30 @@ ...@@ -3,24 +3,30 @@
module Resolvers module Resolvers
module Ci module Ci
class RunnerSetupResolver < BaseResolver class RunnerSetupResolver < BaseResolver
ACCESS_DENIED = 'User is not authorized to register a runner for the specified resource!'
type Types::Ci::RunnerSetupType, null: true type Types::Ci::RunnerSetupType, null: true
description 'Runner setup instructions.' description 'Runner setup instructions.'
argument :platform, GraphQL::STRING_TYPE, argument :platform,
required: true, type: GraphQL::STRING_TYPE,
description: 'Platform to generate the instructions for.' required: true,
description: 'Platform to generate the instructions for.'
argument :architecture, GraphQL::STRING_TYPE, argument :architecture,
required: true, type: GraphQL::STRING_TYPE,
description: 'Architecture to generate the instructions for.' required: true,
description: 'Architecture to generate the instructions for.'
argument :project_id, ::Types::GlobalIDType[::Project], argument :project_id,
required: false, type: ::Types::GlobalIDType[::Project],
description: 'Project to register the runner for.' required: false,
description: 'Project to register the runner for.'
argument :group_id, ::Types::GlobalIDType[::Group], argument :group_id,
required: false, type: ::Types::GlobalIDType[::Group],
description: 'Group to register the runner for.' required: false,
description: 'Group to register the runner for.'
def resolve(platform:, architecture:, **args) def resolve(platform:, architecture:, **args)
instructions = Gitlab::Ci::RunnerInstructions.new( instructions = Gitlab::Ci::RunnerInstructions.new(
...@@ -35,11 +41,15 @@ module Resolvers ...@@ -35,11 +41,15 @@ module Resolvers
register_instructions: instructions.register_command register_instructions: instructions.register_command
} }
ensure ensure
raise Gitlab::Graphql::Errors::ResourceNotAvailable, 'User is not authorized to register a runner for the specified resource!' if instructions.errors.include?('Gitlab::Access::AccessDeniedError') raise Gitlab::Graphql::Errors::ResourceNotAvailable, ACCESS_DENIED if access_denied?(instructions)
end end
private private
def access_denied?(instructions)
instructions.errors.include?('Gitlab::Access::AccessDeniedError')
end
def other_install_instructions(platform) def other_install_instructions(platform)
Gitlab::Ci::RunnerInstructions::OTHER_ENVIRONMENTS[platform.to_sym][:installation_instructions_url] Gitlab::Ci::RunnerInstructions::OTHER_ENVIRONMENTS[platform.to_sym][:installation_instructions_url]
end end
......
...@@ -5,8 +5,10 @@ module Resolvers ...@@ -5,8 +5,10 @@ module Resolvers
type ::GraphQL::STRING_TYPE, null: false type ::GraphQL::STRING_TYPE, null: false
description 'Testing endpoint to validate the API with' description 'Testing endpoint to validate the API with'
argument :text, GraphQL::STRING_TYPE, required: true, argument :text,
description: 'Text to echo back.' type: GraphQL::STRING_TYPE,
required: true,
description: 'Text to echo back.'
def resolve(text:) def resolve(text:)
username = current_user&.username username = current_user&.username
......
# frozen_string_literal: true # frozen_string_literal: true
# rubocop:disable Graphql/ResolverType (inherited from MilestonesResolver)
module Resolvers module Resolvers
class GroupMilestonesResolver < MilestonesResolver class GroupMilestonesResolver < MilestonesResolver
......
...@@ -5,8 +5,8 @@ module Resolvers ...@@ -5,8 +5,8 @@ module Resolvers
type Types::ProjectType.connection_type, null: true type Types::ProjectType.connection_type, null: true
argument :search, GraphQL::STRING_TYPE, argument :search, GraphQL::STRING_TYPE,
required: false, required: false,
description: 'Search query.' description: 'Search query.'
alias_method :user, :object alias_method :user, :object
......
...@@ -10,7 +10,10 @@ module Types ...@@ -10,7 +10,10 @@ module Types
argument :not, NegatedBoardIssueInputType, argument :not, NegatedBoardIssueInputType,
required: false, required: false,
description: 'List of negated params. Warning: this argument is experimental and a subject to change in future.' description: <<~MD
List of negated arguments.
Warning: this argument is experimental and a subject to change in future.
MD
argument :search, GraphQL::STRING_TYPE, argument :search, GraphQL::STRING_TYPE,
required: false, required: false,
......
...@@ -8,39 +8,65 @@ module Types ...@@ -8,39 +8,65 @@ module Types
expose_permissions Types::PermissionTypes::Group expose_permissions Types::PermissionTypes::Group
field :web_url, GraphQL::STRING_TYPE, null: false, field :web_url,
type: GraphQL::STRING_TYPE,
null: false,
description: 'Web URL of the group.' description: 'Web URL of the group.'
field :avatar_url, GraphQL::STRING_TYPE, null: true, field :avatar_url,
type: GraphQL::STRING_TYPE,
null: true,
description: 'Avatar URL of the group.' description: 'Avatar URL of the group.'
field :custom_emoji, Types::CustomEmojiType.connection_type, null: true, field :custom_emoji,
type: Types::CustomEmojiType.connection_type,
null: true,
description: 'Custom emoji within this namespace.', description: 'Custom emoji within this namespace.',
feature_flag: :custom_emoji feature_flag: :custom_emoji
field :share_with_group_lock, GraphQL::BOOLEAN_TYPE, null: true, field :share_with_group_lock,
type: GraphQL::BOOLEAN_TYPE,
null: true,
description: 'Indicates if sharing a project with another group within this group is prevented.' description: 'Indicates if sharing a project with another group within this group is prevented.'
field :project_creation_level, GraphQL::STRING_TYPE, null: true, method: :project_creation_level_str, field :project_creation_level,
type: GraphQL::STRING_TYPE,
null: true,
method: :project_creation_level_str,
description: 'The permission level required to create projects in the group.' description: 'The permission level required to create projects in the group.'
field :subgroup_creation_level, GraphQL::STRING_TYPE, null: true, method: :subgroup_creation_level_str, field :subgroup_creation_level,
type: GraphQL::STRING_TYPE,
null: true,
method: :subgroup_creation_level_str,
description: 'The permission level required to create subgroups within the group.' description: 'The permission level required to create subgroups within the group.'
field :require_two_factor_authentication, GraphQL::BOOLEAN_TYPE, null: true, field :require_two_factor_authentication,
type: GraphQL::BOOLEAN_TYPE,
null: true,
description: 'Indicates if all users in this group are required to set up two-factor authentication.' description: 'Indicates if all users in this group are required to set up two-factor authentication.'
field :two_factor_grace_period, GraphQL::INT_TYPE, null: true, field :two_factor_grace_period,
type: GraphQL::INT_TYPE,
null: true,
description: 'Time before two-factor authentication is enforced.' description: 'Time before two-factor authentication is enforced.'
field :auto_devops_enabled, GraphQL::BOOLEAN_TYPE, null: true, field :auto_devops_enabled,
type: GraphQL::BOOLEAN_TYPE,
null: true,
description: 'Indicates whether Auto DevOps is enabled for all projects within this group.' description: 'Indicates whether Auto DevOps is enabled for all projects within this group.'
field :emails_disabled, GraphQL::BOOLEAN_TYPE, null: true, field :emails_disabled,
type: GraphQL::BOOLEAN_TYPE,
null: true,
description: 'Indicates if a group has email notifications disabled.' description: 'Indicates if a group has email notifications disabled.'
field :mentions_disabled, GraphQL::BOOLEAN_TYPE, null: true, field :mentions_disabled,
type: GraphQL::BOOLEAN_TYPE,
null: true,
description: 'Indicates if a group is disabled from getting mentioned.' description: 'Indicates if a group is disabled from getting mentioned.'
field :parent, GroupType, null: true, field :parent,
type: GroupType,
null: true,
description: 'Parent group.' description: 'Parent group.'
field :issues, field :issues,
...@@ -55,7 +81,7 @@ module Types ...@@ -55,7 +81,7 @@ module Types
description: 'Merge requests for projects in this group.', description: 'Merge requests for projects in this group.',
resolver: Resolvers::GroupMergeRequestsResolver resolver: Resolvers::GroupMergeRequestsResolver
field :milestones, Types::MilestoneType.connection_type, null: true, field :milestones,
description: 'Milestones of the group.', description: 'Milestones of the group.',
resolver: Resolvers::GroupMilestonesResolver resolver: Resolvers::GroupMilestonesResolver
...@@ -76,9 +102,10 @@ module Types ...@@ -76,9 +102,10 @@ module Types
Types::LabelType, Types::LabelType,
null: true, null: true,
description: 'A label available on this group.' do description: 'A label available on this group.' do
argument :title, GraphQL::STRING_TYPE, argument :title,
required: true, type: GraphQL::STRING_TYPE,
description: 'Title of the label.' required: true,
description: 'Title of the label.'
end end
field :group_members, field :group_members,
...@@ -92,7 +119,9 @@ module Types ...@@ -92,7 +119,9 @@ module Types
resolver: Resolvers::ContainerRepositoriesResolver, resolver: Resolvers::ContainerRepositoriesResolver,
authorize: :read_container_image authorize: :read_container_image
field :container_repositories_count, GraphQL::INT_TYPE, null: false, field :container_repositories_count,
type: GraphQL::INT_TYPE,
null: false,
description: 'Number of container repositories in the group.' description: 'Number of container repositories in the group.'
field :packages, field :packages,
......
...@@ -5,12 +5,12 @@ module Types ...@@ -5,12 +5,12 @@ module Types
graphql_name 'JiraUsersMappingInputType' graphql_name 'JiraUsersMappingInputType'
argument :jira_account_id, argument :jira_account_id,
GraphQL::STRING_TYPE, GraphQL::STRING_TYPE,
required: true, required: true,
description: 'Jira account ID of the user.' description: 'Jira account ID of the user.'
argument :gitlab_id, argument :gitlab_id,
GraphQL::INT_TYPE, GraphQL::INT_TYPE,
required: false, required: false,
description: 'Id of the GitLab user.' description: 'ID of the GitLab user.'
end end
end end
...@@ -55,7 +55,10 @@ module Types ...@@ -55,7 +55,10 @@ module Types
field :container_repository, Types::ContainerRepositoryDetailsType, field :container_repository, Types::ContainerRepositoryDetailsType,
null: true, null: true,
description: 'Find a container repository.' do description: 'Find a container repository.' do
argument :id, ::Types::GlobalIDType[::ContainerRepository], required: true, description: 'The global ID of the container repository.' argument :id,
type: ::Types::GlobalIDType[::ContainerRepository],
required: true,
description: 'The global ID of the container repository.'
end end
field :package, field :package,
...@@ -72,9 +75,7 @@ module Types ...@@ -72,9 +75,7 @@ module Types
description: 'Find users.', description: 'Find users.',
resolver: Resolvers::UsersResolver resolver: Resolvers::UsersResolver
field :echo, GraphQL::STRING_TYPE, null: false, field :echo, resolver: Resolvers::EchoResolver
description: 'Text to echo back.',
resolver: Resolvers::EchoResolver
field :issue, Types::IssueType, field :issue, Types::IssueType,
null: true, null: true,
...@@ -102,18 +103,10 @@ module Types ...@@ -102,18 +103,10 @@ module Types
null: true, null: true,
description: 'CI related settings that apply to the entire instance.' description: 'CI related settings that apply to the entire instance.'
field :runner_platforms, Types::Ci::RunnerPlatformType.connection_type, field :runner_platforms, resolver: Resolvers::Ci::RunnerPlatformsResolver
null: true, description: 'Supported runner platforms.', field :runner_setup, resolver: Resolvers::Ci::RunnerSetupResolver
resolver: Resolvers::Ci::RunnerPlatformsResolver
field :runner_setup, Types::Ci::RunnerSetupType, null: true, field :ci_config, resolver: Resolvers::Ci::ConfigResolver, complexity: 126 # AUTHENTICATED_COMPLEXITY / 2 + 1
description: 'Get runner setup instructions.',
resolver: Resolvers::Ci::RunnerSetupResolver
field :ci_config, Types::Ci::Config::ConfigType, null: true,
description: 'Get linted and processed contents of a CI config. Should not be requested more than once per request.',
resolver: Resolvers::Ci::ConfigResolver,
complexity: 126 # AUTHENTICATED_COMPLEXITY / 2 + 1
def design_management def design_management
DesignManagementObject.new(nil) DesignManagementObject.new(nil)
......
...@@ -11,44 +11,72 @@ module Types ...@@ -11,44 +11,72 @@ module Types
expose_permissions Types::PermissionTypes::User expose_permissions Types::PermissionTypes::User
field :id, GraphQL::ID_TYPE, null: false, field :id,
type: GraphQL::ID_TYPE,
null: false,
description: 'ID of the user.' description: 'ID of the user.'
field :bot, GraphQL::BOOLEAN_TYPE, null: false, field :bot,
type: GraphQL::BOOLEAN_TYPE,
null: false,
description: 'Indicates if the user is a bot.', description: 'Indicates if the user is a bot.',
method: :bot? method: :bot?
field :username, GraphQL::STRING_TYPE, null: false, field :username,
type: GraphQL::STRING_TYPE,
null: false,
description: 'Username of the user. Unique within this instance of GitLab.' description: 'Username of the user. Unique within this instance of GitLab.'
field :name, GraphQL::STRING_TYPE, null: false, field :name,
type: GraphQL::STRING_TYPE,
null: false,
description: 'Human-readable name of the user.' description: 'Human-readable name of the user.'
field :state, Types::UserStateEnum, null: false, field :state,
type: Types::UserStateEnum,
null: false,
description: 'State of the user.' description: 'State of the user.'
field :email, GraphQL::STRING_TYPE, null: true, field :email,
type: GraphQL::STRING_TYPE,
null: true,
description: 'User email.', method: :public_email, description: 'User email.', method: :public_email,
deprecated: { reason: :renamed, replacement: 'User.publicEmail', milestone: '13.7' } deprecated: { reason: :renamed, replacement: 'User.publicEmail', milestone: '13.7' }
field :public_email, GraphQL::STRING_TYPE, null: true, field :public_email,
type: GraphQL::STRING_TYPE,
null: true,
description: "User's public email." description: "User's public email."
field :avatar_url, GraphQL::STRING_TYPE, null: true, field :avatar_url,
type: GraphQL::STRING_TYPE,
null: true,
description: "URL of the user's avatar." description: "URL of the user's avatar."
field :web_url, GraphQL::STRING_TYPE, null: false, field :web_url,
type: GraphQL::STRING_TYPE,
null: false,
description: 'Web URL of the user.' description: 'Web URL of the user.'
field :web_path, GraphQL::STRING_TYPE, null: false, field :web_path,
type: GraphQL::STRING_TYPE,
null: false,
description: 'Web path of the user.' description: 'Web path of the user.'
field :todos, Types::TodoType.connection_type, null: false, field :todos,
resolver: Resolvers::TodoResolver, resolver: Resolvers::TodoResolver,
description: 'To-do items of the user.' description: 'To-do items of the user.'
field :group_memberships, Types::GroupMemberType.connection_type, null: true, field :group_memberships,
type: Types::GroupMemberType.connection_type,
null: true,
description: 'Group memberships of the user.' description: 'Group memberships of the user.'
field :group_count, GraphQL::INT_TYPE, null: true, field :group_count,
resolver: Resolvers::Users::GroupCountResolver, resolver: Resolvers::Users::GroupCountResolver,
description: 'Group count for the user.', description: 'Group count for the user.',
feature_flag: :user_group_counts feature_flag: :user_group_counts
field :status, Types::UserStatusType, null: true, field :status,
description: 'User status.' type: Types::UserStatusType,
field :location, ::GraphQL::STRING_TYPE, null: true, null: true,
description: 'User status.'
field :location,
type: ::GraphQL::STRING_TYPE,
null: true,
description: 'The location of the user.' description: 'The location of the user.'
field :project_memberships, Types::ProjectMemberType.connection_type, null: true, field :project_memberships,
type: Types::ProjectMemberType.connection_type,
null: true,
description: 'Project memberships of the user.' description: 'Project memberships of the user.'
field :starred_projects, Types::ProjectType.connection_type, null: true, field :starred_projects,
description: 'Projects starred by the user.', description: 'Projects starred by the user.',
resolver: Resolvers::UserStarredProjectsResolver resolver: Resolvers::UserStarredProjectsResolver
...@@ -64,8 +92,6 @@ module Types ...@@ -64,8 +92,6 @@ module Types
description: 'Merge Requests assigned to the user for review.' description: 'Merge Requests assigned to the user for review.'
field :snippets, field :snippets,
Types::SnippetType.connection_type,
null: true,
description: 'Snippets authored by the user.', description: 'Snippets authored by the user.',
resolver: Resolvers::Users::SnippetsResolver resolver: Resolvers::Users::SnippetsResolver
field :callouts, field :callouts,
......
...@@ -38,7 +38,8 @@ Returns [`CiApplicationSettings`](#ciapplicationsettings). ...@@ -38,7 +38,8 @@ Returns [`CiApplicationSettings`](#ciapplicationsettings).
### `ciConfig` ### `ciConfig`
Get linted and processed contents of a CI config. Should not be requested more than once per request. Linted and processed contents of a CI config.
Should not be requested more than once per request.
Returns [`CiConfig`](#ciconfig). Returns [`CiConfig`](#ciconfig).
...@@ -93,7 +94,7 @@ Returns [`DevopsAdoptionSegmentConnection`](#devopsadoptionsegmentconnection). ...@@ -93,7 +94,7 @@ Returns [`DevopsAdoptionSegmentConnection`](#devopsadoptionsegmentconnection).
### `echo` ### `echo`
Text to echo back. Testing endpoint to validate the API with.
Returns [`String!`](#string). Returns [`String!`](#string).
...@@ -271,7 +272,7 @@ Returns [`RunnerPlatformConnection`](#runnerplatformconnection). ...@@ -271,7 +272,7 @@ Returns [`RunnerPlatformConnection`](#runnerplatformconnection).
### `runnerSetup` ### `runnerSetup`
Get runner setup instructions. Runner setup instructions.
Returns [`RunnerSetup`](#runnersetup). Returns [`RunnerSetup`](#runnersetup).
...@@ -398,7 +399,9 @@ Returns [`VulnerabilitiesCountByDayConnection`](#vulnerabilitiescountbydayconnec ...@@ -398,7 +399,9 @@ Returns [`VulnerabilitiesCountByDayConnection`](#vulnerabilitiescountbydayconnec
### `vulnerabilitiesCountByDayAndSeverity` ### `vulnerabilitiesCountByDayAndSeverity`
Number of vulnerabilities per severity level, per day, for the projects on the current user's instance security dashboard. Number of vulnerabilities per severity level, per day, for the projects on the
current user's instance security dashboard.
.
WARNING: WARNING:
**Deprecated** in 13.3. **Deprecated** in 13.3.
...@@ -6509,7 +6512,7 @@ Representation of a GitLab user. ...@@ -6509,7 +6512,7 @@ Representation of a GitLab user.
| `starredProjects` | [`ProjectConnection`](#projectconnection) | Projects starred by the user. | | `starredProjects` | [`ProjectConnection`](#projectconnection) | Projects starred by the user. |
| `state` | [`UserState!`](#userstate) | State of the user. | | `state` | [`UserState!`](#userstate) | State of the user. |
| `status` | [`UserStatus`](#userstatus) | User status. | | `status` | [`UserStatus`](#userstatus) | User status. |
| `todos` | [`TodoConnection!`](#todoconnection) | To-do items of the user. | | `todos` | [`TodoConnection`](#todoconnection) | To-do items of the user. |
| `userPermissions` | [`UserPermissions!`](#userpermissions) | Permissions for the current user on the resource. | | `userPermissions` | [`UserPermissions!`](#userpermissions) | Permissions for the current user on the resource. |
| `username` | [`String!`](#string) | Username of the user. Unique within this instance of GitLab. | | `username` | [`String!`](#string) | Username of the user. Unique within this instance of GitLab. |
| `webPath` | [`String!`](#string) | Web path of the user. | | `webPath` | [`String!`](#string) | Web path of the user. |
......
...@@ -32,15 +32,20 @@ module EE ...@@ -32,15 +32,20 @@ module EE
field :vulnerabilities_count_by_day, field :vulnerabilities_count_by_day,
::Types::VulnerabilitiesCountByDayType.connection_type, ::Types::VulnerabilitiesCountByDayType.connection_type,
null: true, null: true,
description: "Number of vulnerabilities per day for the projects on the current user's instance security dashboard.", resolver: ::Resolvers::VulnerabilitiesCountPerDayResolver,
resolver: ::Resolvers::VulnerabilitiesCountPerDayResolver description: <<~DESC
Number of vulnerabilities per day for the projects on the current user's instance security dashboard.
DESC
field :vulnerabilities_count_by_day_and_severity, field :vulnerabilities_count_by_day_and_severity,
::Types::VulnerabilitiesCountByDayAndSeverityType.connection_type, ::Types::VulnerabilitiesCountByDayAndSeverityType.connection_type,
null: true, null: true,
description: "Number of vulnerabilities per severity level, per day, for the projects on the current user's instance security dashboard.",
resolver: ::Resolvers::VulnerabilitiesHistoryResolver, resolver: ::Resolvers::VulnerabilitiesHistoryResolver,
deprecated: { reason: :discouraged, replacement: 'Query.vulnerabilitiesCountByDay', milestone: '13.3' } deprecated: { reason: :discouraged, replacement: 'Query.vulnerabilitiesCountByDay', milestone: '13.3' },
description: <<~DESC
Number of vulnerabilities per severity level, per day, for the projects on the
current user's instance security dashboard.
DESC
field :geo_node, ::Types::Geo::GeoNodeType, field :geo_node, ::Types::Geo::GeoNodeType,
null: true, null: true,
......
...@@ -54,6 +54,10 @@ module RuboCop ...@@ -54,6 +54,10 @@ module RuboCop
(send nil? :value ...) (send nil? :value ...)
PATTERN PATTERN
def_node_matcher :resolver_kwarg, <<~PATTERN
(... (hash <(pair (sym :resolver) $_) ...>))
PATTERN
def_node_matcher :description_kwarg, <<~PATTERN def_node_matcher :description_kwarg, <<~PATTERN
(... (hash <(pair (sym :description) $_) ...>)) (... (hash <(pair (sym :description) $_) ...>))
PATTERN PATTERN
...@@ -64,6 +68,7 @@ module RuboCop ...@@ -64,6 +68,7 @@ module RuboCop
def on_send(node) def on_send(node)
return unless graphql_describable?(node) return unless graphql_describable?(node)
return if resolver_kwarg(node) # Fields may inherit the description from their resolvers.
description = locate_description(node) description = locate_description(node)
......
...@@ -6,7 +6,7 @@ require_relative '../../../../rubocop/cop/graphql/descriptions' ...@@ -6,7 +6,7 @@ require_relative '../../../../rubocop/cop/graphql/descriptions'
RSpec.describe RuboCop::Cop::Graphql::Descriptions do RSpec.describe RuboCop::Cop::Graphql::Descriptions do
subject(:cop) { described_class.new } subject(:cop) { described_class.new }
context 'fields' do context 'with fields' do
it 'adds an offense when there is no description' do it 'adds an offense when there is no description' do
expect_offense(<<~TYPE) expect_offense(<<~TYPE)
module Types module Types
...@@ -46,9 +46,19 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do ...@@ -46,9 +46,19 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
end end
TYPE TYPE
end end
it 'does not add an offense when there is a resolver' do
expect_no_offenses(<<~TYPE.strip)
module Types
class FakeType < BaseObject
field :a_thing, resolver: ThingResolver
end
end
TYPE
end
end end
context 'arguments' do context 'with arguments' do
it 'adds an offense when there is no description' do it 'adds an offense when there is no description' do
expect_offense(<<~TYPE) expect_offense(<<~TYPE)
module Types module Types
...@@ -90,7 +100,7 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do ...@@ -90,7 +100,7 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
end end
end end
context 'enum values' do context 'with enum values' do
it 'adds an offense when there is no description' do it 'adds an offense when there is no description' do
expect_offense(<<~TYPE) expect_offense(<<~TYPE)
module Types module Types
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment