2020-10-14 12:08:58 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-08-18 18:10:07 +00:00
|
|
|
require 'rubocop_spec_helper'
|
2020-10-14 12:08:58 +00:00
|
|
|
|
|
|
|
require_relative '../../../../rubocop/cop/graphql/gid_expected_type'
|
|
|
|
|
2021-01-07 18:10:38 +00:00
|
|
|
RSpec.describe RuboCop::Cop::Graphql::GIDExpectedType do
|
2020-10-14 12:08:58 +00:00
|
|
|
it 'adds an offense when there is no expected_type parameter' do
|
2021-01-20 09:10:52 +00:00
|
|
|
expect_offense(<<~TYPE)
|
2020-10-14 12:08:58 +00:00
|
|
|
GitlabSchema.object_from_id(received_id)
|
2021-01-20 09:10:52 +00:00
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Add an expected_type parameter to #object_from_id calls if possible.
|
2020-10-14 12:08:58 +00:00
|
|
|
TYPE
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not add an offense for calls that have an expected_type parameter' do
|
|
|
|
expect_no_offenses(<<~TYPE.strip)
|
|
|
|
GitlabSchema.object_from_id("some_id", expected_type: SomeClass)
|
|
|
|
TYPE
|
|
|
|
end
|
|
|
|
end
|