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/rubocop/cop/graphql/id_type_spec.rb')
-rw-r--r--spec/rubocop/cop/graphql/id_type_spec.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/rubocop/cop/graphql/id_type_spec.rb b/spec/rubocop/cop/graphql/id_type_spec.rb
new file mode 100644
index 00000000000..8767412e282
--- /dev/null
+++ b/spec/rubocop/cop/graphql/id_type_spec.rb
@@ -0,0 +1,36 @@
+# frozen_string_literal: true
+
+require 'fast_spec_helper'
+require 'rubocop'
+
+require_relative '../../../../rubocop/cop/graphql/id_type'
+
+RSpec.describe RuboCop::Cop::Graphql::IDType, type: :rubocop do
+ include CopHelper
+
+ subject(:cop) { described_class.new }
+
+ it 'adds an offense when GraphQL::ID_TYPE is used as a param to #argument' do
+ inspect_source(<<~TYPE)
+ argument :some_arg, GraphQL::ID_TYPE, some: other, params: do_not_matter
+ TYPE
+
+ expect(cop.offenses.size).to eq 1
+ end
+
+ context 'whitelisted arguments' do
+ RuboCop::Cop::Graphql::IDType::WHITELISTED_ARGUMENTS.each do |arg|
+ it "does not add an offense for calls to #argument with #{arg} as argument name" do
+ expect_no_offenses(<<~TYPE.strip)
+ argument #{arg}, GraphQL::ID_TYPE, some: other, params: do_not_matter
+ TYPE
+ end
+ end
+ end
+
+ it 'does not add an offense for calls to #argument without GraphQL::ID_TYPE' do
+ expect_no_offenses(<<~TYPE.strip)
+ argument :some_arg, ::Types::GlobalIDType[::Awardable], some: other, params: do_not_matter
+ TYPE
+ end
+end