diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 12:26:25 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 12:26:25 +0000 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /spec/graphql/types | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) | |
download | gitlab-ce-a09983ae35713f5a2bbb100981116d31ce99826e.tar.gz |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/graphql/types')
107 files changed, 758 insertions, 110 deletions
diff --git a/spec/graphql/types/access_level_enum_spec.rb b/spec/graphql/types/access_level_enum_spec.rb index 05a6d6d5545..eeb10a50b7e 100644 --- a/spec/graphql/types/access_level_enum_spec.rb +++ b/spec/graphql/types/access_level_enum_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['AccessLevelEnum'] do +RSpec.describe GitlabSchema.types['AccessLevelEnum'] do specify { expect(described_class.graphql_name).to eq('AccessLevelEnum') } it 'exposes all the existing access levels' do diff --git a/spec/graphql/types/access_level_type_spec.rb b/spec/graphql/types/access_level_type_spec.rb index b9711a9aa4b..25707ae160d 100644 --- a/spec/graphql/types/access_level_type_spec.rb +++ b/spec/graphql/types/access_level_type_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'spec_helper' -describe GitlabSchema.types['AccessLevel'] do +RSpec.describe GitlabSchema.types['AccessLevel'] do specify { expect(described_class.graphql_name).to eq('AccessLevel') } specify { expect(described_class).to require_graphql_authorizations(nil) } diff --git a/spec/graphql/types/alert_management/alert_status_count_type_spec.rb b/spec/graphql/types/alert_management/alert_status_count_type_spec.rb index 1c56028425e..6372d5dd915 100644 --- a/spec/graphql/types/alert_management/alert_status_count_type_spec.rb +++ b/spec/graphql/types/alert_management/alert_status_count_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['AlertManagementAlertStatusCountsType'] do +RSpec.describe GitlabSchema.types['AlertManagementAlertStatusCountsType'] do specify { expect(described_class.graphql_name).to eq('AlertManagementAlertStatusCountsType') } it 'exposes the expected fields' do diff --git a/spec/graphql/types/alert_management/alert_type_spec.rb b/spec/graphql/types/alert_management/alert_type_spec.rb index 5acbf8ebb7a..45ac673986d 100644 --- a/spec/graphql/types/alert_management/alert_type_spec.rb +++ b/spec/graphql/types/alert_management/alert_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['AlertManagementAlert'] do +RSpec.describe GitlabSchema.types['AlertManagementAlert'] do specify { expect(described_class.graphql_name).to eq('AlertManagementAlert') } specify { expect(described_class).to require_graphql_authorizations(:read_alert_management_alert) } @@ -27,6 +27,7 @@ describe GitlabSchema.types['AlertManagementAlert'] do assignees notes discussions + metrics_dashboard_url ] expect(described_class).to have_graphql_fields(*expected_fields) diff --git a/spec/graphql/types/alert_management/severity_enum_spec.rb b/spec/graphql/types/alert_management/severity_enum_spec.rb index ca5aa826fe5..6c3c962b71d 100644 --- a/spec/graphql/types/alert_management/severity_enum_spec.rb +++ b/spec/graphql/types/alert_management/severity_enum_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['AlertManagementSeverity'] do +RSpec.describe GitlabSchema.types['AlertManagementSeverity'] do specify { expect(described_class.graphql_name).to eq('AlertManagementSeverity') } it 'exposes all the severity values' do diff --git a/spec/graphql/types/alert_management/status_enum_spec.rb b/spec/graphql/types/alert_management/status_enum_spec.rb index 240d8863c97..ac7a8eb53f6 100644 --- a/spec/graphql/types/alert_management/status_enum_spec.rb +++ b/spec/graphql/types/alert_management/status_enum_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['AlertManagementStatus'] do +RSpec.describe GitlabSchema.types['AlertManagementStatus'] do specify { expect(described_class.graphql_name).to eq('AlertManagementStatus') } describe 'statuses' do diff --git a/spec/graphql/types/award_emojis/award_emoji_type_spec.rb b/spec/graphql/types/award_emojis/award_emoji_type_spec.rb index 4e06329506d..3c43c5f8e42 100644 --- a/spec/graphql/types/award_emojis/award_emoji_type_spec.rb +++ b/spec/graphql/types/award_emojis/award_emoji_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['AwardEmoji'] do +RSpec.describe GitlabSchema.types['AwardEmoji'] do specify { expect(described_class.graphql_name).to eq('AwardEmoji') } specify { expect(described_class).to require_graphql_authorizations(:read_emoji) } diff --git a/spec/graphql/types/base_enum_spec.rb b/spec/graphql/types/base_enum_spec.rb index 3eadb492cf5..0d0f6346f2d 100644 --- a/spec/graphql/types/base_enum_spec.rb +++ b/spec/graphql/types/base_enum_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Types::BaseEnum do +RSpec.describe Types::BaseEnum do describe '#enum' do let(:enum) do Class.new(described_class) do diff --git a/spec/graphql/types/base_field_spec.rb b/spec/graphql/types/base_field_spec.rb index 3ec33c75803..73bb54e7ad0 100644 --- a/spec/graphql/types/base_field_spec.rb +++ b/spec/graphql/types/base_field_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Types::BaseField do +RSpec.describe Types::BaseField do context 'when considering complexity' do let(:resolver) do Class.new(described_class) do diff --git a/spec/graphql/types/blob_viewers/type_enum_spec.rb b/spec/graphql/types/blob_viewers/type_enum_spec.rb index 09664382af9..57f052a4fd8 100644 --- a/spec/graphql/types/blob_viewers/type_enum_spec.rb +++ b/spec/graphql/types/blob_viewers/type_enum_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Types::BlobViewers::TypeEnum do +RSpec.describe Types::BlobViewers::TypeEnum do specify { expect(described_class.graphql_name).to eq('BlobViewersType') } it 'exposes all tree entry types' do diff --git a/spec/graphql/types/board_list_type_spec.rb b/spec/graphql/types/board_list_type_spec.rb index 69597fc9617..046d1e92bfa 100644 --- a/spec/graphql/types/board_list_type_spec.rb +++ b/spec/graphql/types/board_list_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['BoardList'] do +RSpec.describe GitlabSchema.types['BoardList'] do specify { expect(described_class.graphql_name).to eq('BoardList') } it 'has specific fields' do diff --git a/spec/graphql/types/board_type_spec.rb b/spec/graphql/types/board_type_spec.rb index 5d87a1757b5..b02b342390d 100644 --- a/spec/graphql/types/board_type_spec.rb +++ b/spec/graphql/types/board_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['Board'] do +RSpec.describe GitlabSchema.types['Board'] do specify { expect(described_class.graphql_name).to eq('Board') } specify { expect(described_class).to require_graphql_authorizations(:read_board) } diff --git a/spec/graphql/types/branch_type_spec.rb b/spec/graphql/types/branch_type_spec.rb index f58b514116d..a5838739a80 100644 --- a/spec/graphql/types/branch_type_spec.rb +++ b/spec/graphql/types/branch_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['Branch'] do +RSpec.describe GitlabSchema.types['Branch'] do it { expect(described_class.graphql_name).to eq('Branch') } it { expect(described_class).to have_graphql_fields(:name, :commit) } diff --git a/spec/graphql/types/ci/detailed_status_type_spec.rb b/spec/graphql/types/ci/detailed_status_type_spec.rb index c62c8f23728..67199848df0 100644 --- a/spec/graphql/types/ci/detailed_status_type_spec.rb +++ b/spec/graphql/types/ci/detailed_status_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Types::Ci::DetailedStatusType do +RSpec.describe Types::Ci::DetailedStatusType do specify { expect(described_class.graphql_name).to eq('DetailedStatus') } it "has all fields" do diff --git a/spec/graphql/types/ci/pipeline_type_spec.rb b/spec/graphql/types/ci/pipeline_type_spec.rb index d56cff12105..f13f1c9afb2 100644 --- a/spec/graphql/types/ci/pipeline_type_spec.rb +++ b/spec/graphql/types/ci/pipeline_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Types::Ci::PipelineType do +RSpec.describe Types::Ci::PipelineType do specify { expect(described_class.graphql_name).to eq('Pipeline') } specify { expect(described_class).to expose_permissions_using(Types::PermissionTypes::Ci::Pipeline) } diff --git a/spec/graphql/types/ci_configuration/sast/analyzers_entity_type_spec.rb b/spec/graphql/types/ci_configuration/sast/analyzers_entity_type_spec.rb new file mode 100644 index 00000000000..34a22feeaf5 --- /dev/null +++ b/spec/graphql/types/ci_configuration/sast/analyzers_entity_type_spec.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['SastCiConfigurationAnalyzersEntity'] do + let(:fields) { %i[name label enabled description] } + + it { expect(described_class.graphql_name).to eq('SastCiConfigurationAnalyzersEntity') } + + it { expect(described_class).to have_graphql_fields(fields) } +end diff --git a/spec/graphql/types/ci_configuration/sast/entity_type_spec.rb b/spec/graphql/types/ci_configuration/sast/entity_type_spec.rb new file mode 100644 index 00000000000..7c6ad013d4a --- /dev/null +++ b/spec/graphql/types/ci_configuration/sast/entity_type_spec.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['SastCiConfigurationEntity'] do + let(:fields) { %i[field label description type options default_value value] } + + it { expect(described_class.graphql_name).to eq('SastCiConfigurationEntity') } + + it { expect(described_class).to have_graphql_fields(fields) } +end diff --git a/spec/graphql/types/ci_configuration/sast/options_entity_spec.rb b/spec/graphql/types/ci_configuration/sast/options_entity_spec.rb new file mode 100644 index 00000000000..c60c8b9c84a --- /dev/null +++ b/spec/graphql/types/ci_configuration/sast/options_entity_spec.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['SastCiConfigurationOptionsEntity'] do + let(:fields) { %i[label value] } + + it { expect(described_class.graphql_name).to eq('SastCiConfigurationOptionsEntity') } + + it { expect(described_class).to have_graphql_fields(fields) } +end diff --git a/spec/graphql/types/ci_configuration/sast/type_spec.rb b/spec/graphql/types/ci_configuration/sast/type_spec.rb new file mode 100644 index 00000000000..e7a8cd436e4 --- /dev/null +++ b/spec/graphql/types/ci_configuration/sast/type_spec.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['SastCiConfiguration'] do + let(:fields) { %i[global pipeline analyzers] } + + it { expect(described_class.graphql_name).to eq('SastCiConfiguration') } + + it { expect(described_class).to have_graphql_fields(fields) } +end diff --git a/spec/graphql/types/commit_action_mode_enum_spec.rb b/spec/graphql/types/commit_action_mode_enum_spec.rb index 9e1a27ea254..cedd466e292 100644 --- a/spec/graphql/types/commit_action_mode_enum_spec.rb +++ b/spec/graphql/types/commit_action_mode_enum_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['CommitActionMode'] do +RSpec.describe GitlabSchema.types['CommitActionMode'] do it { expect(described_class.graphql_name).to eq('CommitActionMode') } it 'exposes all the existing commit actions' do diff --git a/spec/graphql/types/commit_encoding_enum_spec.rb b/spec/graphql/types/commit_encoding_enum_spec.rb index 30686a0c712..7acfb73c06d 100644 --- a/spec/graphql/types/commit_encoding_enum_spec.rb +++ b/spec/graphql/types/commit_encoding_enum_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['CommitEncoding'] do +RSpec.describe GitlabSchema.types['CommitEncoding'] do it { expect(described_class.graphql_name).to eq('CommitEncoding') } it 'exposes all the existing encoding option' do diff --git a/spec/graphql/types/commit_type_spec.rb b/spec/graphql/types/commit_type_spec.rb index 88b450e3924..75984786972 100644 --- a/spec/graphql/types/commit_type_spec.rb +++ b/spec/graphql/types/commit_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['Commit'] do +RSpec.describe GitlabSchema.types['Commit'] do specify { expect(described_class.graphql_name).to eq('Commit') } specify { expect(described_class).to require_graphql_authorizations(:download_code) } diff --git a/spec/graphql/types/container_expiration_policy_cadence_enum_spec.rb b/spec/graphql/types/container_expiration_policy_cadence_enum_spec.rb index 08c777cd365..9bd1fe3ea76 100644 --- a/spec/graphql/types/container_expiration_policy_cadence_enum_spec.rb +++ b/spec/graphql/types/container_expiration_policy_cadence_enum_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['ContainerExpirationPolicyCadenceEnum'] do +RSpec.describe GitlabSchema.types['ContainerExpirationPolicyCadenceEnum'] do let_it_be(:expected_values) { %w[EVERY_DAY EVERY_WEEK EVERY_TWO_WEEKS EVERY_MONTH EVERY_THREE_MONTHS] } it_behaves_like 'exposing container expiration policy option', :cadence diff --git a/spec/graphql/types/container_expiration_policy_keep_enum_spec.rb b/spec/graphql/types/container_expiration_policy_keep_enum_spec.rb index 1a5b4bdd3bb..35385545fe3 100644 --- a/spec/graphql/types/container_expiration_policy_keep_enum_spec.rb +++ b/spec/graphql/types/container_expiration_policy_keep_enum_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['ContainerExpirationPolicyKeepEnum'] do +RSpec.describe GitlabSchema.types['ContainerExpirationPolicyKeepEnum'] do let_it_be(:expected_values) { %w[ONE_TAG FIVE_TAGS TEN_TAGS TWENTY_FIVE_TAGS FIFTY_TAGS ONE_HUNDRED_TAGS] } it_behaves_like 'exposing container expiration policy option', :keep_n diff --git a/spec/graphql/types/container_expiration_policy_older_than_enum_spec.rb b/spec/graphql/types/container_expiration_policy_older_than_enum_spec.rb index 47f0ca22522..72ab605f2e6 100644 --- a/spec/graphql/types/container_expiration_policy_older_than_enum_spec.rb +++ b/spec/graphql/types/container_expiration_policy_older_than_enum_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['ContainerExpirationPolicyOlderThanEnum'] do +RSpec.describe GitlabSchema.types['ContainerExpirationPolicyOlderThanEnum'] do let_it_be(:expected_values) { %w[SEVEN_DAYS FOURTEEN_DAYS THIRTY_DAYS NINETY_DAYS] } it_behaves_like 'exposing container expiration policy option', :older_than diff --git a/spec/graphql/types/container_expiration_policy_type_spec.rb b/spec/graphql/types/container_expiration_policy_type_spec.rb index 8924ab67847..9e9ddaf1cb0 100644 --- a/spec/graphql/types/container_expiration_policy_type_spec.rb +++ b/spec/graphql/types/container_expiration_policy_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['ContainerExpirationPolicy'] do +RSpec.describe GitlabSchema.types['ContainerExpirationPolicy'] do specify { expect(described_class.graphql_name).to eq('ContainerExpirationPolicy') } specify { expect(described_class.description).to eq('A tag expiration policy designed to keep only the images that matter most') } @@ -24,4 +24,20 @@ describe GitlabSchema.types['ContainerExpirationPolicy'] do is_expected.to have_graphql_type(Types::ContainerExpirationPolicyKeepEnum) end end + + describe 'name_regex field' do + subject { described_class.fields['nameRegex'] } + + it 'returns untrusted regexp type' do + is_expected.to have_graphql_type(Types::UntrustedRegexp) + end + end + + describe 'name_regex_keep field' do + subject { described_class.fields['nameRegexKeep'] } + + it 'returns untrusted regexp type' do + is_expected.to have_graphql_type(Types::UntrustedRegexp) + end + end end diff --git a/spec/graphql/types/design_management/design_at_version_type_spec.rb b/spec/graphql/types/design_management/design_at_version_type_spec.rb index 1453d73d59c..5a6292c924a 100644 --- a/spec/graphql/types/design_management/design_at_version_type_spec.rb +++ b/spec/graphql/types/design_management/design_at_version_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['DesignAtVersion'] do +RSpec.describe GitlabSchema.types['DesignAtVersion'] do it_behaves_like 'a GraphQL type with design fields' do let(:extra_design_fields) { %i[version design] } let_it_be(:design) { create(:design, :with_versions) } diff --git a/spec/graphql/types/design_management/design_collection_type_spec.rb b/spec/graphql/types/design_management/design_collection_type_spec.rb index 65150f0971d..6b1d3a87c2d 100644 --- a/spec/graphql/types/design_management/design_collection_type_spec.rb +++ b/spec/graphql/types/design_management/design_collection_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['DesignCollection'] do +RSpec.describe GitlabSchema.types['DesignCollection'] do it { expect(described_class).to require_graphql_authorizations(:read_design) } it 'has the expected fields' do diff --git a/spec/graphql/types/design_management/design_type_spec.rb b/spec/graphql/types/design_management/design_type_spec.rb index 75b4cd66d5e..7a38b397965 100644 --- a/spec/graphql/types/design_management/design_type_spec.rb +++ b/spec/graphql/types/design_management/design_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['Design'] do +RSpec.describe GitlabSchema.types['Design'] do it_behaves_like 'a GraphQL type with design fields' do let(:extra_design_fields) { %i[notes discussions versions] } let_it_be(:design) { create(:design, :with_versions) } diff --git a/spec/graphql/types/design_management/design_version_event_enum_spec.rb b/spec/graphql/types/design_management/design_version_event_enum_spec.rb index a65f1bb5990..06576336231 100644 --- a/spec/graphql/types/design_management/design_version_event_enum_spec.rb +++ b/spec/graphql/types/design_management/design_version_event_enum_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['DesignVersionEvent'] do +RSpec.describe GitlabSchema.types['DesignVersionEvent'] do it { expect(described_class.graphql_name).to eq('DesignVersionEvent') } it 'exposes the correct event states' do diff --git a/spec/graphql/types/design_management/version_type_spec.rb b/spec/graphql/types/design_management/version_type_spec.rb index 3317c4c6571..017cc1775a1 100644 --- a/spec/graphql/types/design_management/version_type_spec.rb +++ b/spec/graphql/types/design_management/version_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['DesignVersion'] do +RSpec.describe GitlabSchema.types['DesignVersion'] do it { expect(described_class).to require_graphql_authorizations(:read_design) } it 'has the expected fields' do diff --git a/spec/graphql/types/design_management_type_spec.rb b/spec/graphql/types/design_management_type_spec.rb index a6204f20f23..e9162feec74 100644 --- a/spec/graphql/types/design_management_type_spec.rb +++ b/spec/graphql/types/design_management_type_spec.rb @@ -2,6 +2,6 @@ require 'spec_helper' -describe GitlabSchema.types['DesignManagement'] do +RSpec.describe GitlabSchema.types['DesignManagement'] do it { expect(described_class).to have_graphql_fields(:version, :design_at_version) } end diff --git a/spec/graphql/types/diff_refs_type_spec.rb b/spec/graphql/types/diff_refs_type_spec.rb index 3165e642452..894191c55ba 100644 --- a/spec/graphql/types/diff_refs_type_spec.rb +++ b/spec/graphql/types/diff_refs_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['DiffRefs'] do +RSpec.describe GitlabSchema.types['DiffRefs'] do specify { expect(described_class.graphql_name).to eq('DiffRefs') } specify { expect(described_class).to have_graphql_fields(:head_sha, :base_sha, :start_sha).only } diff --git a/spec/graphql/types/environment_type_spec.rb b/spec/graphql/types/environment_type_spec.rb index 0e5cbac05df..f7522cb3e2c 100644 --- a/spec/graphql/types/environment_type_spec.rb +++ b/spec/graphql/types/environment_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['Environment'] do +RSpec.describe GitlabSchema.types['Environment'] do specify { expect(described_class.graphql_name).to eq('Environment') } it 'has the expected fields' do diff --git a/spec/graphql/types/error_tracking/sentry_detailed_error_type_spec.rb b/spec/graphql/types/error_tracking/sentry_detailed_error_type_spec.rb index 0a094e9e188..8723c212486 100644 --- a/spec/graphql/types/error_tracking/sentry_detailed_error_type_spec.rb +++ b/spec/graphql/types/error_tracking/sentry_detailed_error_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['SentryDetailedError'] do +RSpec.describe GitlabSchema.types['SentryDetailedError'] do specify { expect(described_class.graphql_name).to eq('SentryDetailedError') } specify { expect(described_class).to require_graphql_authorizations(:read_sentry_issue) } @@ -31,6 +31,8 @@ describe GitlabSchema.types['SentryDetailedError'] do lastReleaseLastCommit firstReleaseShortVersion lastReleaseShortVersion + firstReleaseVersion + lastReleaseVersion gitlabIssuePath gitlabCommit gitlabCommitPath diff --git a/spec/graphql/types/error_tracking/sentry_error_collection_type_spec.rb b/spec/graphql/types/error_tracking/sentry_error_collection_type_spec.rb index 793da2db960..3a8ff7a73be 100644 --- a/spec/graphql/types/error_tracking/sentry_error_collection_type_spec.rb +++ b/spec/graphql/types/error_tracking/sentry_error_collection_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['SentryErrorCollection'] do +RSpec.describe GitlabSchema.types['SentryErrorCollection'] do specify { expect(described_class.graphql_name).to eq('SentryErrorCollection') } specify { expect(described_class).to require_graphql_authorizations(:read_sentry_issue) } diff --git a/spec/graphql/types/error_tracking/sentry_error_stack_trace_entry_type_spec.rb b/spec/graphql/types/error_tracking/sentry_error_stack_trace_entry_type_spec.rb index b65398fccc9..54d0d8edbc6 100644 --- a/spec/graphql/types/error_tracking/sentry_error_stack_trace_entry_type_spec.rb +++ b/spec/graphql/types/error_tracking/sentry_error_stack_trace_entry_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['SentryErrorStackTraceEntry'] do +RSpec.describe GitlabSchema.types['SentryErrorStackTraceEntry'] do specify { expect(described_class.graphql_name).to eq('SentryErrorStackTraceEntry') } it 'exposes the expected fields' do diff --git a/spec/graphql/types/error_tracking/sentry_error_stack_trace_type_spec.rb b/spec/graphql/types/error_tracking/sentry_error_stack_trace_type_spec.rb index 2cec8865764..07ddbd83d0a 100644 --- a/spec/graphql/types/error_tracking/sentry_error_stack_trace_type_spec.rb +++ b/spec/graphql/types/error_tracking/sentry_error_stack_trace_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['SentryErrorStackTrace'] do +RSpec.describe GitlabSchema.types['SentryErrorStackTrace'] do specify { expect(described_class.graphql_name).to eq('SentryErrorStackTrace') } specify { expect(described_class).to require_graphql_authorizations(:read_sentry_issue) } diff --git a/spec/graphql/types/error_tracking/sentry_error_type_spec.rb b/spec/graphql/types/error_tracking/sentry_error_type_spec.rb index f8cc801e35e..6cbcc8888c6 100644 --- a/spec/graphql/types/error_tracking/sentry_error_type_spec.rb +++ b/spec/graphql/types/error_tracking/sentry_error_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['SentryError'] do +RSpec.describe GitlabSchema.types['SentryError'] do specify { expect(described_class.graphql_name).to eq('SentryError') } it 'exposes the expected fields' do diff --git a/spec/graphql/types/evidence_type_spec.rb b/spec/graphql/types/evidence_type_spec.rb index 4a11f7bcda9..92134e74d51 100644 --- a/spec/graphql/types/evidence_type_spec.rb +++ b/spec/graphql/types/evidence_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['ReleaseEvidence'] do +RSpec.describe GitlabSchema.types['ReleaseEvidence'] do it { expect(described_class).to require_graphql_authorizations(:download_code) } it 'has the expected fields' do diff --git a/spec/graphql/types/global_id_type_spec.rb b/spec/graphql/types/global_id_type_spec.rb new file mode 100644 index 00000000000..2a7b26f66b0 --- /dev/null +++ b/spec/graphql/types/global_id_type_spec.rb @@ -0,0 +1,215 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Types::GlobalIDType do + let_it_be(:project) { create(:project) } + let(:gid) { project.to_global_id } + let(:foreign_gid) { GlobalID.new(::URI::GID.build(app: 'otherapp', model_name: 'Project', model_id: project.id, params: nil)) } + + it 'is has the correct name' do + expect(described_class.to_graphql.name).to eq('GlobalID') + end + + describe '.coerce_result' do + it 'can coerce results' do + expect(described_class.coerce_isolated_result(gid)).to eq(gid.to_s) + end + + it 'rejects integer IDs' do + expect { described_class.coerce_isolated_result(project.id) } + .to raise_error(ArgumentError) + end + + it 'rejects strings' do + expect { described_class.coerce_isolated_result('not a GID') } + .to raise_error(ArgumentError) + end + end + + describe '.coerce_input' do + it 'can coerce valid input' do + coerced = described_class.coerce_isolated_input(gid.to_s) + + expect(coerced).to eq(gid) + end + + it 'handles all valid application GIDs' do + expect { described_class.coerce_isolated_input(build_stubbed(:user).to_global_id.to_s) } + .not_to raise_error + end + + it 'rejects invalid input' do + expect { described_class.coerce_isolated_input('not valid') } + .to raise_error(GraphQL::CoercionError) + end + + it 'rejects nil' do + expect { described_class.coerce_isolated_input(nil) } + .to raise_error(GraphQL::CoercionError) + end + + it 'rejects gids from different apps' do + expect { described_class.coerce_isolated_input(foreign_gid) } + .to raise_error(GraphQL::CoercionError) + end + end + + describe 'a parameterized type' do + let(:type) { ::Types::GlobalIDType[::Project] } + + it 'is has the correct name' do + expect(type.to_graphql.name).to eq('ProjectID') + end + + context 'the GID is appropriate' do + it 'can coerce results' do + expect(type.coerce_isolated_result(gid)).to eq(gid.to_s) + end + + it 'can coerce IDs to a GlobalIDType' do + expect(type.coerce_isolated_result(project.id)).to eq(gid.to_s) + end + + it 'can coerce valid input' do + expect(type.coerce_isolated_input(gid.to_s)).to eq(gid) + end + end + + context 'the GID is not for an appropriate type' do + let(:gid) { build_stubbed(:user).to_global_id } + + it 'raises errors when coercing results' do + expect { type.coerce_isolated_result(gid) }.to raise_error(GraphQL::CoercionError) + end + + it 'will not coerce invalid input, even if its a valid GID' do + expect { type.coerce_isolated_input(gid.to_s) } + .to raise_error(GraphQL::CoercionError) + end + end + end + + describe 'a parameterized type with a namespace' do + let(:type) { ::Types::GlobalIDType[::Ci::Build] } + + it 'is has a valid GraphQL identifier for a name' do + expect(type.to_graphql.name).to eq('CiBuildID') + end + end + + describe 'compatibility' do + # Simplified schema to test compatibility + + def query(doc, vars) + GraphQL::Query.new(schema, document: doc, context: {}, variables: vars) + end + + def run_query(gql_query, vars) + query(GraphQL.parse(gql_query), vars).result + end + + all_types = [::GraphQL::ID_TYPE, ::Types::GlobalIDType, ::Types::GlobalIDType[::Project]] + + shared_examples 'a working query' do + let!(:schema) do + # capture values so they can be closed over + arg_type = argument_type + res_type = result_type + + project = Class.new(GraphQL::Schema::Object) do + graphql_name 'Project' + field :name, String, null: false + field :id, res_type, null: false, resolver_method: :global_id + + def global_id + object.to_global_id + end + end + + Class.new(GraphQL::Schema) do + query(Class.new(GraphQL::Schema::Object) do + graphql_name 'Query' + + field :project_by_id, project, null: true do + argument :id, arg_type, required: true + end + + def project_by_id(id:) + gid = ::Types::GlobalIDType[::Project].coerce_isolated_input(id) + gid.model_class.find(gid.model_id) + end + end) + end + end + + it 'works' do + res = run_query(document, 'projectId' => project.to_global_id.to_s) + + expect(res['errors']).to be_blank + expect(res.dig('data', 'project', 'name')).to eq(project.name) + expect(res.dig('data', 'project', 'id')).to eq(project.to_global_id.to_s) + end + end + + context 'when the argument is declared as ID' do + let(:document) do + <<-GRAPHQL + query($projectId: ID!){ + project: projectById(id: $projectId) { + name, id + } + } + GRAPHQL + end + + let(:argument_type) { ::GraphQL::ID_TYPE } + + where(:result_type) { all_types } + + with_them do + it_behaves_like 'a working query' + end + end + + context 'when the argument is declared as GlobalID' do + let(:document) do + <<-GRAPHQL + query($projectId: GlobalID!) { + project: projectById(id: $projectId) { + name, id + } + } + GRAPHQL + end + + let(:argument_type) { ::Types::GlobalIDType } + + where(:result_type) { all_types } + + with_them do + it_behaves_like 'a working query' + end + end + + context 'when the argument is declared as ProjectID' do + let(:document) do + <<-GRAPHQL + query($projectId: ProjectID!) { + project: projectById(id: $projectId) { + name, id + } + } + GRAPHQL + end + + let(:argument_type) { ::Types::GlobalIDType[::Project] } + + where(:result_type) { all_types } + + with_them do + it_behaves_like 'a working query' + end + end + end +end diff --git a/spec/graphql/types/grafana_integration_type_spec.rb b/spec/graphql/types/grafana_integration_type_spec.rb index 429b5bdffe6..b4658db08d7 100644 --- a/spec/graphql/types/grafana_integration_type_spec.rb +++ b/spec/graphql/types/grafana_integration_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['GrafanaIntegration'] do +RSpec.describe GitlabSchema.types['GrafanaIntegration'] do let(:expected_fields) do %i[ id diff --git a/spec/graphql/types/group_member_type_spec.rb b/spec/graphql/types/group_member_type_spec.rb index 5d09e60d21c..b1cb8e572ad 100644 --- a/spec/graphql/types/group_member_type_spec.rb +++ b/spec/graphql/types/group_member_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Types::GroupMemberType do +RSpec.describe Types::GroupMemberType do specify { expect(described_class).to expose_permissions_using(Types::PermissionTypes::Group) } specify { expect(described_class.graphql_name).to eq('GroupMember') } diff --git a/spec/graphql/types/group_type_spec.rb b/spec/graphql/types/group_type_spec.rb index c56cd40ef12..fb79e9bb85b 100644 --- a/spec/graphql/types/group_type_spec.rb +++ b/spec/graphql/types/group_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['Group'] do +RSpec.describe GitlabSchema.types['Group'] do specify { expect(described_class).to expose_permissions_using(Types::PermissionTypes::Group) } specify { expect(described_class.graphql_name).to eq('Group') } diff --git a/spec/graphql/types/issuable_sort_enum_spec.rb b/spec/graphql/types/issuable_sort_enum_spec.rb index 35c42d8194c..e5237256a2b 100644 --- a/spec/graphql/types/issuable_sort_enum_spec.rb +++ b/spec/graphql/types/issuable_sort_enum_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Types::IssuableSortEnum do +RSpec.describe Types::IssuableSortEnum do specify { expect(described_class.graphql_name).to eq('IssuableSort') } it 'exposes all the existing issuable sort values' do diff --git a/spec/graphql/types/issuable_state_enum_spec.rb b/spec/graphql/types/issuable_state_enum_spec.rb index f974ed5f5fb..a63b8cddb14 100644 --- a/spec/graphql/types/issuable_state_enum_spec.rb +++ b/spec/graphql/types/issuable_state_enum_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['IssuableState'] do +RSpec.describe GitlabSchema.types['IssuableState'] do specify { expect(described_class.graphql_name).to eq('IssuableState') } it_behaves_like 'issuable state' diff --git a/spec/graphql/types/issue_connection_type_spec.rb b/spec/graphql/types/issue_connection_type_spec.rb new file mode 100644 index 00000000000..af34611ecfe --- /dev/null +++ b/spec/graphql/types/issue_connection_type_spec.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['IssueConnection'] do + it 'has the expected fields' do + expected_fields = %i[count page_info edges nodes] + + expect(described_class).to have_graphql_fields(*expected_fields) + end +end diff --git a/spec/graphql/types/issue_sort_enum_spec.rb b/spec/graphql/types/issue_sort_enum_spec.rb index c496b897cdb..9313d3aee84 100644 --- a/spec/graphql/types/issue_sort_enum_spec.rb +++ b/spec/graphql/types/issue_sort_enum_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['IssueSort'] do +RSpec.describe GitlabSchema.types['IssueSort'] do specify { expect(described_class.graphql_name).to eq('IssueSort') } it_behaves_like 'common sort values' diff --git a/spec/graphql/types/issue_state_enum_spec.rb b/spec/graphql/types/issue_state_enum_spec.rb index a18c5f5d317..a9dd287e196 100644 --- a/spec/graphql/types/issue_state_enum_spec.rb +++ b/spec/graphql/types/issue_state_enum_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['IssueState'] do +RSpec.describe GitlabSchema.types['IssueState'] do specify { expect(described_class.graphql_name).to eq('IssueState') } it_behaves_like 'issuable state' diff --git a/spec/graphql/types/issue_type_spec.rb b/spec/graphql/types/issue_type_spec.rb index a8f7edcfe8e..4a86b07ab1c 100644 --- a/spec/graphql/types/issue_type_spec.rb +++ b/spec/graphql/types/issue_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['Issue'] do +RSpec.describe GitlabSchema.types['Issue'] do specify { expect(described_class).to expose_permissions_using(Types::PermissionTypes::Issue) } specify { expect(described_class.graphql_name).to eq('Issue') } @@ -12,7 +12,7 @@ describe GitlabSchema.types['Issue'] do specify { expect(described_class.interfaces).to include(Types::Notes::NoteableType) } it 'has specific fields' do - fields = %i[iid title description state reference author assignees participants labels milestone due_date + fields = %i[id iid title description state reference author assignees participants labels milestone due_date confidential discussion_locked upvotes downvotes user_notes_count web_path web_url relative_position subscribed time_estimate total_time_spent closed_at created_at updated_at task_completion_status designs design_collection] @@ -22,6 +22,104 @@ describe GitlabSchema.types['Issue'] do end end + describe 'pagination and count' do + let_it_be(:user) { create(:user) } + let_it_be(:project) { create(:project, :public) } + let_it_be(:now) { Time.now.change(usec: 0) } + let_it_be(:issues) { create_list(:issue, 10, project: project, created_at: now) } + + let(:count_path) { %w(data project issues count) } + let(:page_size) { 3 } + let(:query) do + <<~GRAPHQL + query project($fullPath: ID!, $first: Int, $after: String) { + project(fullPath: $fullPath) { + issues(first: $first, after: $after) { + count + edges { + node { + iid + } + } + pageInfo { + endCursor + hasNextPage + } + } + } + } + GRAPHQL + end + + subject do + GitlabSchema.execute( + query, + context: { current_user: user }, + variables: { + fullPath: project.full_path, + first: page_size + } + ).to_h + end + + context 'when user does not have the permission' do + it 'returns no data' do + allow(Ability).to receive(:allowed?).with(user, :read_project, project).and_return(false) + + expect(subject.dig(:data, :project)).to eq(nil) + end + end + + context 'count' do + let(:end_cursor) { %w(data project issues pageInfo endCursor) } + let(:issues_edges) { %w(data project issues edges) } + + it 'returns total count' do + expect(subject.dig(*count_path)).to eq(issues.count) + end + + it 'total count does not change between pages' do + old_count = subject.dig(*count_path) + new_cursor = subject.dig(*end_cursor) + + new_page = GitlabSchema.execute( + query, + context: { current_user: user }, + variables: { + fullPath: project.full_path, + first: page_size, + after: new_cursor + } + ).to_h + + new_count = new_page.dig(*count_path) + expect(old_count).to eq(new_count) + end + + context 'pagination' do + let(:page_size) { 9 } + + it 'returns new ids during pagination' do + old_edges = subject.dig(*issues_edges) + new_cursor = subject.dig(*end_cursor) + + new_edges = GitlabSchema.execute( + query, + context: { current_user: user }, + variables: { + fullPath: project.full_path, + first: page_size, + after: new_cursor + } + ).to_h.dig(*issues_edges) + + expect(old_edges.count).to eq(9) + expect(new_edges.count).to eq(1) + end + end + end + end + describe "issue notes" do let(:user) { create(:user) } let(:project) { create(:project, :public) } diff --git a/spec/graphql/types/jira_import_type_spec.rb b/spec/graphql/types/jira_import_type_spec.rb index fa1152aec41..b44525d3304 100644 --- a/spec/graphql/types/jira_import_type_spec.rb +++ b/spec/graphql/types/jira_import_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['JiraImport'] do +RSpec.describe GitlabSchema.types['JiraImport'] do specify { expect(described_class.graphql_name).to eq('JiraImport') } it 'has the expected fields' do diff --git a/spec/graphql/types/jira_user_type_spec.rb b/spec/graphql/types/jira_user_type_spec.rb new file mode 100644 index 00000000000..6e55efb42f4 --- /dev/null +++ b/spec/graphql/types/jira_user_type_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['JiraUser'] do + specify { expect(described_class.graphql_name).to eq('JiraUser') } + + it 'has the expected fields' do + expect(described_class).to have_graphql_fields( + :jira_account_id, :jira_display_name, :jira_email, :gitlab_id, :gitlab_username, :gitlab_name + ) + end +end diff --git a/spec/graphql/types/label_type_spec.rb b/spec/graphql/types/label_type_spec.rb index 026c63906ef..6a999a2e925 100644 --- a/spec/graphql/types/label_type_spec.rb +++ b/spec/graphql/types/label_type_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'spec_helper' -describe GitlabSchema.types['Label'] do +RSpec.describe GitlabSchema.types['Label'] do it 'has the correct fields' do expected_fields = [:id, :description, :description_html, :title, :color, :text_color] diff --git a/spec/graphql/types/merge_request_state_enum_spec.rb b/spec/graphql/types/merge_request_state_enum_spec.rb index 2abc7b298b1..6fc5803a5d0 100644 --- a/spec/graphql/types/merge_request_state_enum_spec.rb +++ b/spec/graphql/types/merge_request_state_enum_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['MergeRequestState'] do +RSpec.describe GitlabSchema.types['MergeRequestState'] do specify { expect(described_class.graphql_name).to eq('MergeRequestState') } it_behaves_like 'issuable state' diff --git a/spec/graphql/types/merge_request_type_spec.rb b/spec/graphql/types/merge_request_type_spec.rb index 0f48264c99f..b3dccde8ce3 100644 --- a/spec/graphql/types/merge_request_type_spec.rb +++ b/spec/graphql/types/merge_request_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['MergeRequest'] do +RSpec.describe GitlabSchema.types['MergeRequest'] do specify { expect(described_class).to expose_permissions_using(Types::PermissionTypes::MergeRequest) } specify { expect(described_class).to require_graphql_authorizations(:read_merge_request) } @@ -15,7 +15,8 @@ describe GitlabSchema.types['MergeRequest'] do description_html state created_at updated_at source_project target_project project project_id source_project_id target_project_id source_branch target_branch work_in_progress merge_when_pipeline_succeeds diff_head_sha - merge_commit_sha user_notes_count should_remove_source_branch diff_refs + merge_commit_sha user_notes_count should_remove_source_branch + diff_refs diff_stats diff_stats_summary force_remove_source_branch merge_status in_progress_merge_commit_sha merge_error allow_collaboration should_be_rebased rebase_commit_sha rebase_in_progress merge_commit_message default_merge_commit_message diff --git a/spec/graphql/types/metadata_type_spec.rb b/spec/graphql/types/metadata_type_spec.rb index 75369ec9c3c..a1efb0a03d5 100644 --- a/spec/graphql/types/metadata_type_spec.rb +++ b/spec/graphql/types/metadata_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['Metadata'] do +RSpec.describe GitlabSchema.types['Metadata'] do specify { expect(described_class.graphql_name).to eq('Metadata') } specify { expect(described_class).to require_graphql_authorizations(:read_instance_metadata) } end diff --git a/spec/graphql/types/metrics/dashboard_type_spec.rb b/spec/graphql/types/metrics/dashboard_type_spec.rb index 0dbd0d8b38d..30dccc7c0be 100644 --- a/spec/graphql/types/metrics/dashboard_type_spec.rb +++ b/spec/graphql/types/metrics/dashboard_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['MetricsDashboard'] do +RSpec.describe GitlabSchema.types['MetricsDashboard'] do specify { expect(described_class.graphql_name).to eq('MetricsDashboard') } it 'has the expected fields' do diff --git a/spec/graphql/types/metrics/dashboards/annotation_type_spec.rb b/spec/graphql/types/metrics/dashboards/annotation_type_spec.rb index dbb8b04dbd7..12c5eec937c 100644 --- a/spec/graphql/types/metrics/dashboards/annotation_type_spec.rb +++ b/spec/graphql/types/metrics/dashboards/annotation_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['MetricsDashboardAnnotation'] do +RSpec.describe GitlabSchema.types['MetricsDashboardAnnotation'] do specify { expect(described_class.graphql_name).to eq('MetricsDashboardAnnotation') } it 'has the expected fields' do diff --git a/spec/graphql/types/milestone_stats_type_spec.rb b/spec/graphql/types/milestone_stats_type_spec.rb new file mode 100644 index 00000000000..1ccb275c922 --- /dev/null +++ b/spec/graphql/types/milestone_stats_type_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['MilestoneStats'] do + it { expect(described_class).to require_graphql_authorizations(:read_milestone) } + + it 'has the expected fields' do + expected_fields = %w[ + total_issues_count closed_issues_count + ] + + expect(described_class).to include_graphql_fields(*expected_fields) + end +end diff --git a/spec/graphql/types/milestone_type_spec.rb b/spec/graphql/types/milestone_type_spec.rb index 4c3d9f50a64..2315c10433b 100644 --- a/spec/graphql/types/milestone_type_spec.rb +++ b/spec/graphql/types/milestone_type_spec.rb @@ -2,8 +2,25 @@ require 'spec_helper' -describe GitlabSchema.types['Milestone'] do +RSpec.describe GitlabSchema.types['Milestone'] do specify { expect(described_class.graphql_name).to eq('Milestone') } specify { expect(described_class).to require_graphql_authorizations(:read_milestone) } + + it 'has the expected fields' do + expected_fields = %w[ + id title description state web_path + due_date start_date created_at updated_at + project_milestone group_milestone subgroup_milestone + stats + ] + + expect(described_class).to have_graphql_fields(*expected_fields) + end + + describe 'stats field' do + subject { described_class.fields['stats'] } + + it { is_expected.to have_graphql_type(Types::MilestoneStatsType) } + end end diff --git a/spec/graphql/types/mutation_type_spec.rb b/spec/graphql/types/mutation_type_spec.rb index a67d83b1edf..41993327577 100644 --- a/spec/graphql/types/mutation_type_spec.rb +++ b/spec/graphql/types/mutation_type_spec.rb @@ -2,8 +2,34 @@ require 'spec_helper' -describe Types::MutationType do +RSpec.describe Types::MutationType do it 'is expected to have the MergeRequestSetWip' do expect(described_class).to have_graphql_mutation(Mutations::MergeRequests::SetWip) end + + describe 'deprecated and aliased mutations' do + using RSpec::Parameterized::TableSyntax + + where(:alias_name, :canonical_name) do + 'AddAwardEmoji' | 'AwardEmojiAdd' + 'RemoveAwardEmoji' | 'AwardEmojiRemove' + 'ToggleAwardEmoji' | 'AwardEmojiToggle' + end + + with_them do + let(:alias_field) { get_field(alias_name) } + let(:canonical_field) { get_field(canonical_name) } + + it { expect(alias_field).to be_present } + it { expect(canonical_field).to be_present } + it { expect(alias_field.deprecation_reason).to be_present } + it { expect(canonical_field.deprecation_reason).not_to be_present } + it { expect(alias_field.resolver.fields).to eq(canonical_field.resolver.fields) } + it { expect(alias_field.resolver.arguments).to eq(canonical_field.resolver.arguments) } + end + + def get_field(name) + described_class.fields[GraphqlHelpers.fieldnamerize(name)] + end + end end diff --git a/spec/graphql/types/namespace_type_spec.rb b/spec/graphql/types/namespace_type_spec.rb index 741698021e7..2ed1ee3e8c4 100644 --- a/spec/graphql/types/namespace_type_spec.rb +++ b/spec/graphql/types/namespace_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['Namespace'] do +RSpec.describe GitlabSchema.types['Namespace'] do specify { expect(described_class.graphql_name).to eq('Namespace') } it 'has the expected fields' do @@ -11,7 +11,7 @@ describe GitlabSchema.types['Namespace'] do lfs_enabled request_access_enabled projects root_storage_statistics ] - expect(described_class).to have_graphql_fields(*expected_fields) + expect(described_class).to include_graphql_fields(*expected_fields) end specify { expect(described_class).to require_graphql_authorizations(:read_namespace) } diff --git a/spec/graphql/types/notes/diff_position_type_spec.rb b/spec/graphql/types/notes/diff_position_type_spec.rb index 87f3810d55c..1515c2f66d7 100644 --- a/spec/graphql/types/notes/diff_position_type_spec.rb +++ b/spec/graphql/types/notes/diff_position_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['DiffPosition'] do +RSpec.describe GitlabSchema.types['DiffPosition'] do it 'exposes the expected fields' do expected_fields = %i[ diff_refs diff --git a/spec/graphql/types/notes/discussion_type_spec.rb b/spec/graphql/types/notes/discussion_type_spec.rb index 177000b01b2..37ed861d069 100644 --- a/spec/graphql/types/notes/discussion_type_spec.rb +++ b/spec/graphql/types/notes/discussion_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['Discussion'] do +RSpec.describe GitlabSchema.types['Discussion'] do it 'exposes the expected fields' do expected_fields = %i[ created_at diff --git a/spec/graphql/types/notes/note_type_spec.rb b/spec/graphql/types/notes/note_type_spec.rb index d6cd0800234..180d13d35d2 100644 --- a/spec/graphql/types/notes/note_type_spec.rb +++ b/spec/graphql/types/notes/note_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['Note'] do +RSpec.describe GitlabSchema.types['Note'] do it 'exposes the expected fields' do expected_fields = %i[ author @@ -19,6 +19,7 @@ describe GitlabSchema.types['Note'] do resolved_at resolved_by system + system_note_icon_name updated_at user_permissions ] diff --git a/spec/graphql/types/notes/noteable_type_spec.rb b/spec/graphql/types/notes/noteable_type_spec.rb index 88d8eae56d1..fad24c6fed4 100644 --- a/spec/graphql/types/notes/noteable_type_spec.rb +++ b/spec/graphql/types/notes/noteable_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Types::Notes::NoteableType do +RSpec.describe Types::Notes::NoteableType do it 'exposes the expected fields' do expected_fields = %i[ discussions diff --git a/spec/graphql/types/package_type_enum_spec.rb b/spec/graphql/types/package_type_enum_spec.rb new file mode 100644 index 00000000000..fadec9744ed --- /dev/null +++ b/spec/graphql/types/package_type_enum_spec.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['PackageTypeEnum'] do + it 'exposes all package types' do + expect(described_class.values.keys).to contain_exactly(*%w[MAVEN NPM CONAN NUGET PYPI COMPOSER]) + end +end diff --git a/spec/graphql/types/package_type_spec.rb b/spec/graphql/types/package_type_spec.rb new file mode 100644 index 00000000000..22048e7a693 --- /dev/null +++ b/spec/graphql/types/package_type_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['Package'] do + it { expect(described_class.graphql_name).to eq('Package') } + + it 'includes all the package fields' do + expected_fields = %w[ + id name version created_at updated_at package_type + ] + + expect(described_class).to include_graphql_fields(*expected_fields) + end +end diff --git a/spec/graphql/types/permission_types/base_permission_type_spec.rb b/spec/graphql/types/permission_types/base_permission_type_spec.rb index 4c6d5fd369a..2ce02f1520c 100644 --- a/spec/graphql/types/permission_types/base_permission_type_spec.rb +++ b/spec/graphql/types/permission_types/base_permission_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Types::PermissionTypes::BasePermissionType do +RSpec.describe Types::PermissionTypes::BasePermissionType do let(:permitable) { double('permittable') } let(:current_user) { build(:user) } let(:context) { { current_user: current_user } } diff --git a/spec/graphql/types/permission_types/issue_spec.rb b/spec/graphql/types/permission_types/issue_spec.rb index a7a3dd00f11..58c5808cbcc 100644 --- a/spec/graphql/types/permission_types/issue_spec.rb +++ b/spec/graphql/types/permission_types/issue_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Types::PermissionTypes::Issue do +RSpec.describe Types::PermissionTypes::Issue do it do expected_permissions = [ :read_issue, :admin_issue, :update_issue, :reopen_issue, diff --git a/spec/graphql/types/permission_types/merge_request_spec.rb b/spec/graphql/types/permission_types/merge_request_spec.rb index e0f8bdd4712..73a178540a6 100644 --- a/spec/graphql/types/permission_types/merge_request_spec.rb +++ b/spec/graphql/types/permission_types/merge_request_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Types::PermissionTypes::MergeRequest do +RSpec.describe Types::PermissionTypes::MergeRequest do it do expected_permissions = [ :read_merge_request, :admin_merge_request, :update_merge_request, diff --git a/spec/graphql/types/permission_types/merge_request_type_spec.rb b/spec/graphql/types/permission_types/merge_request_type_spec.rb index 7e9752cdc46..7dd1d3bca06 100644 --- a/spec/graphql/types/permission_types/merge_request_type_spec.rb +++ b/spec/graphql/types/permission_types/merge_request_type_spec.rb @@ -2,6 +2,6 @@ require 'spec_helper' -describe Types::MergeRequestType do +RSpec.describe Types::MergeRequestType do specify { expect(described_class).to expose_permissions_using(Types::PermissionTypes::MergeRequest) } end diff --git a/spec/graphql/types/permission_types/note_spec.rb b/spec/graphql/types/permission_types/note_spec.rb index a2becb6892b..9769c7b3aa3 100644 --- a/spec/graphql/types/permission_types/note_spec.rb +++ b/spec/graphql/types/permission_types/note_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['NotePermissions'] do +RSpec.describe GitlabSchema.types['NotePermissions'] do it 'has the expected fields' do expected_permissions = [ :read_note, :create_note, :admin_note, :resolve_note, :award_emoji diff --git a/spec/graphql/types/permission_types/project_spec.rb b/spec/graphql/types/permission_types/project_spec.rb index 2789464d29c..c6853a0eadc 100644 --- a/spec/graphql/types/permission_types/project_spec.rb +++ b/spec/graphql/types/permission_types/project_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Types::PermissionTypes::Project do +RSpec.describe Types::PermissionTypes::Project do it do expected_permissions = [ :change_namespace, :change_visibility_level, :rename_project, :remove_project, :archive_project, diff --git a/spec/graphql/types/permission_types/snippet_spec.rb b/spec/graphql/types/permission_types/snippet_spec.rb index 66e9fa6dfdb..e2caa1c52c2 100644 --- a/spec/graphql/types/permission_types/snippet_spec.rb +++ b/spec/graphql/types/permission_types/snippet_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Types::PermissionTypes::Snippet do +RSpec.describe Types::PermissionTypes::Snippet do it 'returns the snippets permissions' do expected_permissions = [ :create_note, :award_emoji, :read_snippet, :update_snippet, :admin_snippet, :report_snippet diff --git a/spec/graphql/types/permission_types/user_spec.rb b/spec/graphql/types/permission_types/user_spec.rb index 1e8201db568..6f0d380f763 100644 --- a/spec/graphql/types/permission_types/user_spec.rb +++ b/spec/graphql/types/permission_types/user_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Types::PermissionTypes::User do +RSpec.describe Types::PermissionTypes::User do it 'returns user permissions' do expected_permissions = [ :create_snippet diff --git a/spec/graphql/types/project_member_type_spec.rb b/spec/graphql/types/project_member_type_spec.rb index 1b1f6c24a32..65c89557ec1 100644 --- a/spec/graphql/types/project_member_type_spec.rb +++ b/spec/graphql/types/project_member_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Types::ProjectMemberType do +RSpec.describe Types::ProjectMemberType do specify { expect(described_class).to expose_permissions_using(Types::PermissionTypes::Project) } specify { expect(described_class.graphql_name).to eq('ProjectMember') } diff --git a/spec/graphql/types/project_statistics_type_spec.rb b/spec/graphql/types/project_statistics_type_spec.rb index fbea780494b..e6cffd407de 100644 --- a/spec/graphql/types/project_statistics_type_spec.rb +++ b/spec/graphql/types/project_statistics_type_spec.rb @@ -2,10 +2,10 @@ require 'spec_helper' -describe GitlabSchema.types['ProjectStatistics'] do - it "has all the required fields" do +RSpec.describe GitlabSchema.types['ProjectStatistics'] do + it 'has all the required fields' do expect(described_class).to have_graphql_fields(:storage_size, :repository_size, :lfs_objects_size, :build_artifacts_size, :packages_size, :commit_count, - :wiki_size) + :wiki_size, :snippets_size) end end diff --git a/spec/graphql/types/project_type_spec.rb b/spec/graphql/types/project_type_spec.rb index 8ee9aa9cf3a..ea88ed6a3f5 100644 --- a/spec/graphql/types/project_type_spec.rb +++ b/spec/graphql/types/project_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['Project'] do +RSpec.describe GitlabSchema.types['Project'] do specify { expect(described_class).to expose_permissions_using(Types::PermissionTypes::Project) } specify { expect(described_class.graphql_name).to eq('Project') } @@ -26,7 +26,7 @@ describe GitlabSchema.types['Project'] do grafanaIntegration autocloseReferencedIssues suggestion_commit_message environments boards jira_import_status jira_imports services releases release alert_management_alerts alert_management_alert alert_management_alert_status_counts - container_expiration_policy + container_expiration_policy sast_ci_configuration service_desk_enabled service_desk_address ] expect(described_class).to include_graphql_fields(*expected_fields) @@ -140,5 +140,93 @@ describe GitlabSchema.types['Project'] do it { is_expected.to have_graphql_type(Types::ContainerExpirationPolicyType) } end + describe 'sast_ci_configuration' do + let_it_be(:project) { create(:project) } + let_it_be(:user) { create(:user) } + let_it_be(:query) do + %( + query { + project(fullPath: "#{project.full_path}") { + sastCiConfiguration { + global { + nodes { + type + options { + nodes { + label + value + } + } + field + label + defaultValue + value + } + } + pipeline { + nodes { + type + options { + nodes { + label + value + } + } + field + label + defaultValue + value + } + } + analyzers { + nodes { + name + label + enabled + } + } + } + } + } + ) + end + + subject { GitlabSchema.execute(query, context: { current_user: user }).as_json } + + before do + project.add_developer(user) + end + + it "returns the project's sast configuration for global variables" do + query_result = subject.dig('data', 'project', 'sastCiConfiguration', 'global', 'nodes') + first_config = query_result.first + fourth_config = query_result[3] + expect(first_config['type']).to eq('string') + expect(first_config['field']).to eq('SECURE_ANALYZERS_PREFIX') + expect(first_config['label']).to eq('Image prefix') + expect(first_config['defaultValue']).to eq('registry.gitlab.com/gitlab-org/security-products/analyzers') + expect(first_config['value']).to eq('') + expect(first_config['options']).to be_nil + expect(fourth_config['options']['nodes']).to match([{ "value" => "true", "label" => "true (disables SAST)" }, + { "value" => "false", "label" => "false (enables SAST)" }]) + end + + it "returns the project's sast configuration for pipeline variables" do + configuration = subject.dig('data', 'project', 'sastCiConfiguration', 'pipeline', 'nodes').first + expect(configuration['type']).to eq('dropdown') + expect(configuration['field']).to eq('stage') + expect(configuration['label']).to eq('Stage') + expect(configuration['defaultValue']).to eq('test') + expect(configuration['value']).to eq('') + end + + it "returns the project's sast configuration for analyzer variables" do + configuration = subject.dig('data', 'project', 'sastCiConfiguration', 'analyzers', 'nodes').first + expect(configuration['name']).to eq('brakeman') + expect(configuration['label']).to eq('Brakeman') + expect(configuration['enabled']).to eq(true) + end + end + it_behaves_like 'a GraphQL type with labels' end diff --git a/spec/graphql/types/projects/base_service_type_spec.rb b/spec/graphql/types/projects/base_service_type_spec.rb index 4fcb9fe1a73..423cea860d7 100644 --- a/spec/graphql/types/projects/base_service_type_spec.rb +++ b/spec/graphql/types/projects/base_service_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['BaseService'] do +RSpec.describe GitlabSchema.types['BaseService'] do specify { expect(described_class.graphql_name).to eq('BaseService') } it 'has basic expected fields' do diff --git a/spec/graphql/types/projects/jira_project_type_spec.rb b/spec/graphql/types/projects/jira_project_type_spec.rb index cbb01117717..60b4c5c5276 100644 --- a/spec/graphql/types/projects/jira_project_type_spec.rb +++ b/spec/graphql/types/projects/jira_project_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['JiraProject'] do +RSpec.describe GitlabSchema.types['JiraProject'] do it { expect(described_class.graphql_name).to eq('JiraProject') } it 'has basic expected fields' do diff --git a/spec/graphql/types/projects/jira_service_type_spec.rb b/spec/graphql/types/projects/jira_service_type_spec.rb index fad0c91caab..9db580ac963 100644 --- a/spec/graphql/types/projects/jira_service_type_spec.rb +++ b/spec/graphql/types/projects/jira_service_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['JiraService'] do +RSpec.describe GitlabSchema.types['JiraService'] do specify { expect(described_class.graphql_name).to eq('JiraService') } it 'has basic expected fields' do diff --git a/spec/graphql/types/projects/service_type_spec.rb b/spec/graphql/types/projects/service_type_spec.rb index f6758d17d18..f110322ac89 100644 --- a/spec/graphql/types/projects/service_type_spec.rb +++ b/spec/graphql/types/projects/service_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Types::Projects::ServiceType do +RSpec.describe Types::Projects::ServiceType do specify { expect(described_class).to have_graphql_fields(:type, :active) } describe ".resolve_type" do diff --git a/spec/graphql/types/projects/services_enum_spec.rb b/spec/graphql/types/projects/services_enum_spec.rb index 91e398e8d81..dac1213daf3 100644 --- a/spec/graphql/types/projects/services_enum_spec.rb +++ b/spec/graphql/types/projects/services_enum_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['ServiceType'] do +RSpec.describe GitlabSchema.types['ServiceType'] do specify { expect(described_class.graphql_name).to eq('ServiceType') } it 'exposes all the existing project services' do diff --git a/spec/graphql/types/query_type_spec.rb b/spec/graphql/types/query_type_spec.rb index 1194391c26a..081f99a8307 100644 --- a/spec/graphql/types/query_type_spec.rb +++ b/spec/graphql/types/query_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['Query'] do +RSpec.describe GitlabSchema.types['Query'] do it 'is called Query' do expect(described_class.graphql_name).to eq('Query') end diff --git a/spec/graphql/types/release_asset_link_type_spec.rb b/spec/graphql/types/release_asset_link_type_spec.rb new file mode 100644 index 00000000000..679431012cf --- /dev/null +++ b/spec/graphql/types/release_asset_link_type_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['ReleaseAssetLink'] do + it { expect(described_class).to require_graphql_authorizations(:read_release) } + + it 'has the expected fields' do + expected_fields = %w[ + id name url external link_type + ] + + expect(described_class).to include_graphql_fields(*expected_fields) + end +end diff --git a/spec/graphql/types/release_assets_type_spec.rb b/spec/graphql/types/release_assets_type_spec.rb index 58f0f7ee697..0166f87bf47 100644 --- a/spec/graphql/types/release_assets_type_spec.rb +++ b/spec/graphql/types/release_assets_type_spec.rb @@ -2,12 +2,12 @@ require 'spec_helper' -describe GitlabSchema.types['ReleaseAssets'] do +RSpec.describe GitlabSchema.types['ReleaseAssets'] do it { expect(described_class).to require_graphql_authorizations(:read_release) } it 'has the expected fields' do expected_fields = %w[ - assets_count links sources + count links sources ] expect(described_class).to include_graphql_fields(*expected_fields) @@ -16,7 +16,7 @@ describe GitlabSchema.types['ReleaseAssets'] do describe 'links field' do subject { described_class.fields['links'] } - it { is_expected.to have_graphql_type(Types::ReleaseLinkType.connection_type) } + it { is_expected.to have_graphql_type(Types::ReleaseAssetLinkType.connection_type) } end describe 'sources field' do diff --git a/spec/graphql/types/release_links_type_spec.rb b/spec/graphql/types/release_links_type_spec.rb index 49e04e120f4..d505f0a4b5c 100644 --- a/spec/graphql/types/release_links_type_spec.rb +++ b/spec/graphql/types/release_links_type_spec.rb @@ -2,12 +2,15 @@ require 'spec_helper' -describe GitlabSchema.types['ReleaseLink'] do - it { expect(described_class).to require_graphql_authorizations(:read_release) } +RSpec.describe GitlabSchema.types['ReleaseLinks'] do + it { expect(described_class).to require_graphql_authorizations(:download_code) } it 'has the expected fields' do expected_fields = %w[ - id name url external link_type + selfUrl + mergeRequestsUrl + issuesUrl + editUrl ] expect(described_class).to include_graphql_fields(*expected_fields) diff --git a/spec/graphql/types/release_source_type_spec.rb b/spec/graphql/types/release_source_type_spec.rb index e471ac1a5ac..69a1ca30dbc 100644 --- a/spec/graphql/types/release_source_type_spec.rb +++ b/spec/graphql/types/release_source_type_spec.rb @@ -2,8 +2,8 @@ require 'spec_helper' -describe GitlabSchema.types['ReleaseSource'] do - it { expect(described_class).to require_graphql_authorizations(:read_release_sources) } +RSpec.describe GitlabSchema.types['ReleaseSource'] do + it { expect(described_class).to require_graphql_authorizations(:download_code) } it 'has the expected fields' do expected_fields = %w[ diff --git a/spec/graphql/types/release_type_spec.rb b/spec/graphql/types/release_type_spec.rb index feafe5ed519..0c05a68c5a6 100644 --- a/spec/graphql/types/release_type_spec.rb +++ b/spec/graphql/types/release_type_spec.rb @@ -2,14 +2,15 @@ require 'spec_helper' -describe GitlabSchema.types['Release'] do +RSpec.describe GitlabSchema.types['Release'] do it { expect(described_class).to require_graphql_authorizations(:read_release) } it 'has the expected fields' do expected_fields = %w[ tag_name tag_path description description_html - name assets milestones evidences author commit + name milestones evidences author commit + assets links created_at released_at ] @@ -22,6 +23,12 @@ describe GitlabSchema.types['Release'] do it { is_expected.to have_graphql_type(Types::ReleaseAssetsType) } end + describe 'links field' do + subject { described_class.fields['links'] } + + it { is_expected.to have_graphql_type(Types::ReleaseLinksType) } + end + describe 'milestones field' do subject { described_class.fields['milestones'] } @@ -44,6 +51,5 @@ describe GitlabSchema.types['Release'] do subject { described_class.fields['commit'] } it { is_expected.to have_graphql_type(Types::CommitType) } - it { is_expected.to require_graphql_authorizations(:reporter_access) } end end diff --git a/spec/graphql/types/repository_type_spec.rb b/spec/graphql/types/repository_type_spec.rb index fb52839c712..27780476421 100644 --- a/spec/graphql/types/repository_type_spec.rb +++ b/spec/graphql/types/repository_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['Repository'] do +RSpec.describe GitlabSchema.types['Repository'] do specify { expect(described_class.graphql_name).to eq('Repository') } specify { expect(described_class).to require_graphql_authorizations(:download_code) } diff --git a/spec/graphql/types/resolvable_interface_spec.rb b/spec/graphql/types/resolvable_interface_spec.rb index 231287f9969..25370f8d527 100644 --- a/spec/graphql/types/resolvable_interface_spec.rb +++ b/spec/graphql/types/resolvable_interface_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Types::ResolvableInterface do +RSpec.describe Types::ResolvableInterface do it 'exposes the expected fields' do expected_fields = %i[ resolvable diff --git a/spec/graphql/types/root_storage_statistics_type_spec.rb b/spec/graphql/types/root_storage_statistics_type_spec.rb index ebaa5a18623..f01c55cbccb 100644 --- a/spec/graphql/types/root_storage_statistics_type_spec.rb +++ b/spec/graphql/types/root_storage_statistics_type_spec.rb @@ -2,12 +2,12 @@ require 'spec_helper' -describe GitlabSchema.types['RootStorageStatistics'] do +RSpec.describe GitlabSchema.types['RootStorageStatistics'] do specify { expect(described_class.graphql_name).to eq('RootStorageStatistics') } it 'has all the required fields' do expect(described_class).to have_graphql_fields(:storage_size, :repository_size, :lfs_objects_size, - :build_artifacts_size, :packages_size, :wiki_size) + :build_artifacts_size, :packages_size, :wiki_size, :snippets_size) end specify { expect(described_class).to require_graphql_authorizations(:read_statistics) } diff --git a/spec/graphql/types/snippet_type_spec.rb b/spec/graphql/types/snippet_type_spec.rb index f24419ce9cc..0341ca2c733 100644 --- a/spec/graphql/types/snippet_type_spec.rb +++ b/spec/graphql/types/snippet_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['Snippet'] do +RSpec.describe GitlabSchema.types['Snippet'] do let_it_be(:user) { create(:user) } it 'has the correct fields' do diff --git a/spec/graphql/types/snippets/blob_type_spec.rb b/spec/graphql/types/snippets/blob_type_spec.rb index fb8c6896732..bfac08f40d3 100644 --- a/spec/graphql/types/snippets/blob_type_spec.rb +++ b/spec/graphql/types/snippets/blob_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['SnippetBlob'] do +RSpec.describe GitlabSchema.types['SnippetBlob'] do it 'has the correct fields' do expected_fields = [:rich_data, :plain_data, :raw_path, :size, :binary, :name, :path, diff --git a/spec/graphql/types/snippets/blob_viewer_type_spec.rb b/spec/graphql/types/snippets/blob_viewer_type_spec.rb index 841e22451db..8210eb9a95c 100644 --- a/spec/graphql/types/snippets/blob_viewer_type_spec.rb +++ b/spec/graphql/types/snippets/blob_viewer_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['SnippetBlobViewer'] do +RSpec.describe GitlabSchema.types['SnippetBlobViewer'] do let_it_be(:snippet) { create(:personal_snippet, :repository) } let_it_be(:blob) { snippet.repository.blob_at('HEAD', 'files/images/6049019_460s.jpg') } diff --git a/spec/graphql/types/snippets/file_input_action_enum_spec.rb b/spec/graphql/types/snippets/file_input_action_enum_spec.rb index 2ccc8b04b8f..ff9b706240b 100644 --- a/spec/graphql/types/snippets/file_input_action_enum_spec.rb +++ b/spec/graphql/types/snippets/file_input_action_enum_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Types::Snippets::FileInputActionEnum do +RSpec.describe Types::Snippets::FileInputActionEnum do specify { expect(described_class.graphql_name).to eq('SnippetFileInputActionEnum') } it 'exposes all file input action types' do diff --git a/spec/graphql/types/snippets/file_input_type_spec.rb b/spec/graphql/types/snippets/file_input_type_spec.rb index 62e5caf20b7..c7d4909b542 100644 --- a/spec/graphql/types/snippets/file_input_type_spec.rb +++ b/spec/graphql/types/snippets/file_input_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Types::Snippets::FileInputType do +RSpec.describe Types::Snippets::FileInputType do specify { expect(described_class.graphql_name).to eq('SnippetFileInputType') } it 'has the correct arguments' do diff --git a/spec/graphql/types/time_type_spec.rb b/spec/graphql/types/time_type_spec.rb index 3c6e191e2fb..68d346766c2 100644 --- a/spec/graphql/types/time_type_spec.rb +++ b/spec/graphql/types/time_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['Time'] do +RSpec.describe GitlabSchema.types['Time'] do let(:iso) { "2018-06-04T15:23:50+02:00" } let(:time) { Time.parse(iso) } diff --git a/spec/graphql/types/todo_type_spec.rb b/spec/graphql/types/todo_type_spec.rb index 87a5405f0e2..15b6195ec5c 100644 --- a/spec/graphql/types/todo_type_spec.rb +++ b/spec/graphql/types/todo_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['Todo'] do +RSpec.describe GitlabSchema.types['Todo'] do it 'has the correct fields' do expected_fields = [:id, :project, :group, :author, :action, :target_type, :body, :state, :created_at] diff --git a/spec/graphql/types/tree/blob_type_spec.rb b/spec/graphql/types/tree/blob_type_spec.rb index 547a03b5edf..73d61d4860c 100644 --- a/spec/graphql/types/tree/blob_type_spec.rb +++ b/spec/graphql/types/tree/blob_type_spec.rb @@ -2,8 +2,8 @@ require 'spec_helper' -describe Types::Tree::BlobType do +RSpec.describe Types::Tree::BlobType do specify { expect(described_class.graphql_name).to eq('Blob') } - specify { expect(described_class).to have_graphql_fields(:id, :sha, :name, :type, :path, :flat_path, :web_url, :lfs_oid) } + specify { expect(described_class).to have_graphql_fields(:id, :sha, :name, :type, :path, :flat_path, :web_url, :lfs_oid, :mode) } end diff --git a/spec/graphql/types/tree/submodule_type_spec.rb b/spec/graphql/types/tree/submodule_type_spec.rb index b5cfe8eb812..ba2b06f1907 100644 --- a/spec/graphql/types/tree/submodule_type_spec.rb +++ b/spec/graphql/types/tree/submodule_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Types::Tree::SubmoduleType do +RSpec.describe Types::Tree::SubmoduleType do specify { expect(described_class.graphql_name).to eq('Submodule') } specify { expect(described_class).to have_graphql_fields(:id, :sha, :name, :type, :path, :flat_path, :web_url, :tree_url) } diff --git a/spec/graphql/types/tree/tree_entry_type_spec.rb b/spec/graphql/types/tree/tree_entry_type_spec.rb index 14826d06645..0e5caf66854 100644 --- a/spec/graphql/types/tree/tree_entry_type_spec.rb +++ b/spec/graphql/types/tree/tree_entry_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Types::Tree::TreeEntryType do +RSpec.describe Types::Tree::TreeEntryType do specify { expect(described_class.graphql_name).to eq('TreeEntry') } specify { expect(described_class).to have_graphql_fields(:id, :sha, :name, :type, :path, :flat_path, :web_url) } diff --git a/spec/graphql/types/tree/tree_type_spec.rb b/spec/graphql/types/tree/tree_type_spec.rb index 93faebd3602..362ecdfca91 100644 --- a/spec/graphql/types/tree/tree_type_spec.rb +++ b/spec/graphql/types/tree/tree_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Types::Tree::TreeType do +RSpec.describe Types::Tree::TreeType do specify { expect(described_class.graphql_name).to eq('Tree') } specify { expect(described_class).to have_graphql_fields(:trees, :submodules, :blobs, :last_commit) } diff --git a/spec/graphql/types/tree/type_enum_spec.rb b/spec/graphql/types/tree/type_enum_spec.rb index dcacd6073f9..f751bcf2a13 100644 --- a/spec/graphql/types/tree/type_enum_spec.rb +++ b/spec/graphql/types/tree/type_enum_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Types::Tree::TypeEnum do +RSpec.describe Types::Tree::TypeEnum do specify { expect(described_class.graphql_name).to eq('EntryType') } it 'exposes all tree entry types' do diff --git a/spec/graphql/types/untrusted_regexp_spec.rb b/spec/graphql/types/untrusted_regexp_spec.rb new file mode 100644 index 00000000000..c801c62fbdc --- /dev/null +++ b/spec/graphql/types/untrusted_regexp_spec.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['UntrustedRegexp'] do + using RSpec::Parameterized::TableSyntax + + specify { expect(described_class.graphql_name).to eq('UntrustedRegexp') } + + specify { expect(described_class.description).to eq('A regexp containing patterns sourced from user input') } + + describe '.coerce_input' do + subject { described_class.coerce_input(input, nil) } + + where(:input, :expected_result) do + '.*' | '.*' + '(.*)' | '(.*)' + '[test*]+' | '[test*]+' + '*v1' | :raise_error + '[test*' | :raise_error + 'test*+' | :raise_error + end + + with_them do + context "with input #{params[:input]}" do + if params[:expected_result] == :raise_error + it 'raises a coercion error' do + expect { subject }.to raise_error(GraphQL::CoercionError, /#{Regexp.quote(input)} is an invalid regexp/) + end + else + it { expect(subject).to eq(expected_result) } + end + end + end + end + + describe '.coerce_result' do + subject { described_class.coerce_result(input, nil) } + + where(:input, :expected_result) do + '1' | '1' + 1 | '1' + true | 'true' + end + + with_them do + context "with input #{params[:input]}" do + it { expect(subject).to eq(expected_result) } + end + end + end +end diff --git a/spec/graphql/types/user_type_spec.rb b/spec/graphql/types/user_type_spec.rb index 7b34588b0ff..6cc3f7bcaa1 100644 --- a/spec/graphql/types/user_type_spec.rb +++ b/spec/graphql/types/user_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabSchema.types['User'] do +RSpec.describe GitlabSchema.types['User'] do specify { expect(described_class.graphql_name).to eq('User') } specify { expect(described_class).to require_graphql_authorizations(:read_user) } |