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>2022-02-18 00:14:40 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-02-18 00:14:40 +0300
commit0c8b3354d966bf689a11736b80460fa5806b4495 (patch)
tree31259c03d4875aca416f422c912cc9b4d8a291a1 /spec/rubocop/cop/graphql
parentae845b62778b7c82aae1828b5f237e0468993ef8 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/rubocop/cop/graphql')
-rw-r--r--spec/rubocop/cop/graphql/graphql_name_position_spec.rb44
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/rubocop/cop/graphql/graphql_name_position_spec.rb b/spec/rubocop/cop/graphql/graphql_name_position_spec.rb
new file mode 100644
index 00000000000..42cc398ed84
--- /dev/null
+++ b/spec/rubocop/cop/graphql/graphql_name_position_spec.rb
@@ -0,0 +1,44 @@
+# frozen_string_literal: true
+
+require 'fast_spec_helper'
+
+require_relative '../../../../rubocop/cop/graphql/graphql_name_position'
+
+RSpec.describe RuboCop::Cop::Graphql::GraphqlNamePosition do
+ subject(:cop) { described_class.new }
+
+ it 'adds an offense when graphql_name is not on the first line' do
+ expect_offense(<<~TYPE)
+ module Types
+ class AType < BaseObject
+ ^^^^^^^^^^^^^^^^^^^^^^^^ `graphql_name` should be the first line of the class: https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#naming-conventions
+ field :a_thing
+ field :another_thing
+ graphql_name 'ATypeName'
+ end
+ end
+ TYPE
+ end
+
+ it 'does not add an offense for classes that have no call to graphql_name' do
+ expect_no_offenses(<<~TYPE.strip)
+ module Types
+ class AType < BaseObject
+ authorize :an_ability, :second_ability
+
+ field :a_thing
+ end
+ end
+ TYPE
+ end
+
+ it 'does not add an offense for classes that only call graphql_name' do
+ expect_no_offenses(<<~TYPE.strip)
+ module Types
+ class AType < BaseObject
+ graphql_name 'ATypeName'
+ end
+ end
+ TYPE
+ end
+end