diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-16 21:18:33 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-16 21:18:33 +0300 |
commit | f64a639bcfa1fc2bc89ca7db268f594306edfd7c (patch) | |
tree | a2c3c2ebcc3b45e596949db485d6ed18ffaacfa1 /spec/rubocop/cop/graphql | |
parent | bfbc3e0d6583ea1a91f627528bedc3d65ba4b10f (diff) |
Add latest changes from gitlab-org/gitlab@13-10-stable-eev13.10.0-rc40
Diffstat (limited to 'spec/rubocop/cop/graphql')
-rw-r--r-- | spec/rubocop/cop/graphql/authorize_types_spec.rb | 31 | ||||
-rw-r--r-- | spec/rubocop/cop/graphql/descriptions_spec.rb | 45 | ||||
-rw-r--r-- | spec/rubocop/cop/graphql/gid_expected_type_spec.rb | 1 | ||||
-rw-r--r-- | spec/rubocop/cop/graphql/id_type_spec.rb | 1 | ||||
-rw-r--r-- | spec/rubocop/cop/graphql/json_type_spec.rb | 1 | ||||
-rw-r--r-- | spec/rubocop/cop/graphql/resolver_type_spec.rb | 1 |
6 files changed, 74 insertions, 6 deletions
diff --git a/spec/rubocop/cop/graphql/authorize_types_spec.rb b/spec/rubocop/cop/graphql/authorize_types_spec.rb index 9242b865b20..6c521789e34 100644 --- a/spec/rubocop/cop/graphql/authorize_types_spec.rb +++ b/spec/rubocop/cop/graphql/authorize_types_spec.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require 'fast_spec_helper' -require 'rubocop' require_relative '../../../../rubocop/cop/graphql/authorize_types' @@ -63,4 +62,34 @@ RSpec.describe RuboCop::Cop::Graphql::AuthorizeTypes do end TYPE end + + it 'does not add an offense for subtypes of BaseUnion' do + expect_no_offenses(<<~TYPE) + module Types + class AType < BaseUnion + possible_types Types::Foo, Types::Bar + end + end + TYPE + end + + it 'does not add an offense for subtypes of BaseInputObject' do + expect_no_offenses(<<~TYPE) + module Types + class AType < BaseInputObject + argument :a_thing + end + end + TYPE + end + + it 'does not add an offense for InputTypes' do + expect_no_offenses(<<~TYPE) + module Types + class AInputType < SomeObjectType + argument :a_thing + end + end + TYPE + end end diff --git a/spec/rubocop/cop/graphql/descriptions_spec.rb b/spec/rubocop/cop/graphql/descriptions_spec.rb index 9ad40fad83d..af660aee165 100644 --- a/spec/rubocop/cop/graphql/descriptions_spec.rb +++ b/spec/rubocop/cop/graphql/descriptions_spec.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require 'fast_spec_helper' -require 'rubocop' require_relative '../../../../rubocop/cop/graphql/descriptions' RSpec.describe RuboCop::Cop::Graphql::Descriptions do @@ -91,6 +90,50 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do end end + context 'enum values' do + it 'adds an offense when there is no description' do + expect_offense(<<~TYPE) + module Types + class FakeEnum < BaseEnum + value 'FOO', value: 'foo' + ^^^^^^^^^^^^^^^^^^^^^^^^^ Please add a `description` property. + end + end + TYPE + end + + it 'adds an offense when description does not end in a period' do + expect_offense(<<~TYPE) + module Types + class FakeEnum < BaseEnum + value 'FOO', value: 'foo', description: 'bar' + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `description` strings must end with a `.`. + end + end + TYPE + end + + it 'does not add an offense when description is correct (defined using `description:`)' do + expect_no_offenses(<<~TYPE.strip) + module Types + class FakeEnum < BaseEnum + value 'FOO', value: 'foo', description: 'bar.' + end + end + TYPE + end + + it 'does not add an offense when description is correct (defined as a second argument)' do + expect_no_offenses(<<~TYPE.strip) + module Types + class FakeEnum < BaseEnum + value 'FOO', 'bar.', value: 'foo' + end + end + TYPE + end + end + describe 'autocorrecting descriptions without periods' do it 'can autocorrect' do expect_offense(<<~TYPE) diff --git a/spec/rubocop/cop/graphql/gid_expected_type_spec.rb b/spec/rubocop/cop/graphql/gid_expected_type_spec.rb index d9a129244d6..47a6ce24d53 100644 --- a/spec/rubocop/cop/graphql/gid_expected_type_spec.rb +++ b/spec/rubocop/cop/graphql/gid_expected_type_spec.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require 'fast_spec_helper' -require 'rubocop' require_relative '../../../../rubocop/cop/graphql/gid_expected_type' diff --git a/spec/rubocop/cop/graphql/id_type_spec.rb b/spec/rubocop/cop/graphql/id_type_spec.rb index 93c01cd7f06..a566488b118 100644 --- a/spec/rubocop/cop/graphql/id_type_spec.rb +++ b/spec/rubocop/cop/graphql/id_type_spec.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require 'fast_spec_helper' -require 'rubocop' require_relative '../../../../rubocop/cop/graphql/id_type' diff --git a/spec/rubocop/cop/graphql/json_type_spec.rb b/spec/rubocop/cop/graphql/json_type_spec.rb index 91838c1708e..50437953c1d 100644 --- a/spec/rubocop/cop/graphql/json_type_spec.rb +++ b/spec/rubocop/cop/graphql/json_type_spec.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require 'fast_spec_helper' -require 'rubocop' require_relative '../../../../rubocop/cop/graphql/json_type' RSpec.describe RuboCop::Cop::Graphql::JSONType do diff --git a/spec/rubocop/cop/graphql/resolver_type_spec.rb b/spec/rubocop/cop/graphql/resolver_type_spec.rb index 11c0ad284a9..06bf90a8a07 100644 --- a/spec/rubocop/cop/graphql/resolver_type_spec.rb +++ b/spec/rubocop/cop/graphql/resolver_type_spec.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require 'fast_spec_helper' -require 'rubocop' require_relative '../../../../rubocop/cop/graphql/resolver_type' |