diff options
Diffstat (limited to 'spec/graphql/types')
23 files changed, 164 insertions, 22 deletions
diff --git a/spec/graphql/types/alert_management/prometheus_integration_type_spec.rb b/spec/graphql/types/alert_management/prometheus_integration_type_spec.rb index 31cf94aef44..bfb6958e327 100644 --- a/spec/graphql/types/alert_management/prometheus_integration_type_spec.rb +++ b/spec/graphql/types/alert_management/prometheus_integration_type_spec.rb @@ -50,7 +50,7 @@ RSpec.describe GitlabSchema.types['AlertManagementPrometheusIntegration'] do describe 'a group integration' do let_it_be(:group) { create(:group) } - let_it_be(:integration) { create(:prometheus_integration, project: nil, group: group) } + let_it_be(:integration) { create(:prometheus_integration, :group, group: group) } # Since it is impossible to authorize the parent here, given that the # project is nil, all fields should be redacted: diff --git a/spec/graphql/types/ci/job_artifact_type_spec.rb b/spec/graphql/types/ci/job_artifact_type_spec.rb index d4dc5ef214d..58b5f9cfcb7 100644 --- a/spec/graphql/types/ci/job_artifact_type_spec.rb +++ b/spec/graphql/types/ci/job_artifact_type_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' RSpec.describe GitlabSchema.types['CiJobArtifact'] do it 'has the correct fields' do - expected_fields = [:download_path, :file_type] + expected_fields = [:download_path, :file_type, :name] expect(described_class).to have_graphql_fields(*expected_fields) end diff --git a/spec/graphql/types/ci/pipeline_scope_enum_spec.rb b/spec/graphql/types/ci/pipeline_scope_enum_spec.rb new file mode 100644 index 00000000000..9dc6e5c6fae --- /dev/null +++ b/spec/graphql/types/ci/pipeline_scope_enum_spec.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Types::Ci::PipelineScopeEnum do + it 'exposes all pipeline scopes' do + expect(described_class.values.keys).to contain_exactly( + *::Ci::PipelinesFinder::ALLOWED_SCOPES.keys.map(&:to_s) + ) + end +end diff --git a/spec/graphql/types/ci/pipeline_status_enum_spec.rb b/spec/graphql/types/ci/pipeline_status_enum_spec.rb new file mode 100644 index 00000000000..2d6683c6384 --- /dev/null +++ b/spec/graphql/types/ci/pipeline_status_enum_spec.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Types::Ci::PipelineStatusEnum do + it 'exposes all pipeline states' do + expect(described_class.values.keys).to contain_exactly( + *::Ci::Pipeline.all_state_names.map(&:to_s).map(&:upcase) + ) + end +end diff --git a/spec/graphql/types/ci/pipeline_type_spec.rb b/spec/graphql/types/ci/pipeline_type_spec.rb index 8c849114cf6..58724524785 100644 --- a/spec/graphql/types/ci/pipeline_type_spec.rb +++ b/spec/graphql/types/ci/pipeline_type_spec.rb @@ -12,8 +12,8 @@ RSpec.describe Types::Ci::PipelineType do id iid sha before_sha complete status detailed_status config_source duration queued_duration coverage created_at updated_at started_at finished_at committed_at - stages user retryable cancelable jobs source_job job downstream - upstream path project active user_permissions warnings commit_path uses_needs + stages user retryable cancelable jobs source_job job job_artifacts downstream + upstream path project active user_permissions warnings commit commit_path uses_needs test_report_summary test_suite ref ] diff --git a/spec/graphql/types/commit_type_spec.rb b/spec/graphql/types/commit_type_spec.rb index b43693e5804..2f74ce81761 100644 --- a/spec/graphql/types/commit_type_spec.rb +++ b/spec/graphql/types/commit_type_spec.rb @@ -9,7 +9,7 @@ RSpec.describe GitlabSchema.types['Commit'] do it 'contains attributes related to commit' do expect(described_class).to have_graphql_fields( - :id, :sha, :short_id, :title, :description, :description_html, :message, :title_html, :authored_date, + :id, :sha, :short_id, :title, :full_title, :full_title_html, :description, :description_html, :message, :title_html, :authored_date, :author_name, :author_gravatar, :author, :web_url, :web_path, :pipelines, :signature_html ) diff --git a/spec/graphql/types/customer_relations/contact_type_spec.rb b/spec/graphql/types/customer_relations/contact_type_spec.rb index a51ee705fb0..bb447f405b6 100644 --- a/spec/graphql/types/customer_relations/contact_type_spec.rb +++ b/spec/graphql/types/customer_relations/contact_type_spec.rb @@ -7,5 +7,5 @@ RSpec.describe GitlabSchema.types['CustomerRelationsContact'] do it { expect(described_class.graphql_name).to eq('CustomerRelationsContact') } it { expect(described_class).to have_graphql_fields(fields) } - it { expect(described_class).to require_graphql_authorizations(:read_contact) } + it { expect(described_class).to require_graphql_authorizations(:read_crm_contact) } end diff --git a/spec/graphql/types/customer_relations/organization_type_spec.rb b/spec/graphql/types/customer_relations/organization_type_spec.rb index 2562748477c..93844df1239 100644 --- a/spec/graphql/types/customer_relations/organization_type_spec.rb +++ b/spec/graphql/types/customer_relations/organization_type_spec.rb @@ -7,5 +7,5 @@ RSpec.describe GitlabSchema.types['CustomerRelationsOrganization'] do it { expect(described_class.graphql_name).to eq('CustomerRelationsOrganization') } it { expect(described_class).to have_graphql_fields(fields) } - it { expect(described_class).to require_graphql_authorizations(:read_organization) } + it { expect(described_class).to require_graphql_authorizations(:read_crm_organization) } end diff --git a/spec/graphql/types/dependency_proxy/manifest_type_spec.rb b/spec/graphql/types/dependency_proxy/manifest_type_spec.rb index 18cc89adfcb..b251ca63c4f 100644 --- a/spec/graphql/types/dependency_proxy/manifest_type_spec.rb +++ b/spec/graphql/types/dependency_proxy/manifest_type_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' RSpec.describe GitlabSchema.types['DependencyProxyManifest'] do it 'includes dependency proxy manifest fields' do expected_fields = %w[ - file_name image_name size created_at updated_at digest + id file_name image_name size created_at updated_at digest ] expect(described_class).to include_graphql_fields(*expected_fields) diff --git a/spec/graphql/types/evidence_type_spec.rb b/spec/graphql/types/evidence_type_spec.rb index 92134e74d51..be85724eac5 100644 --- a/spec/graphql/types/evidence_type_spec.rb +++ b/spec/graphql/types/evidence_type_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe GitlabSchema.types['ReleaseEvidence'] do - it { expect(described_class).to require_graphql_authorizations(:download_code) } + specify { expect(described_class).to require_graphql_authorizations(:read_release_evidence) } it 'has the expected fields' do expected_fields = %w[ diff --git a/spec/graphql/types/merge_request_review_state_enum_spec.rb b/spec/graphql/types/merge_request_review_state_enum_spec.rb index 486e1c4f502..407a1ae3c1f 100644 --- a/spec/graphql/types/merge_request_review_state_enum_spec.rb +++ b/spec/graphql/types/merge_request_review_state_enum_spec.rb @@ -12,6 +12,10 @@ RSpec.describe GitlabSchema.types['MergeRequestReviewState'] do 'UNREVIEWED' => have_attributes( description: 'The merge request is unreviewed.', value: 'unreviewed' + ), + 'ATTENTION_REQUESTED' => have_attributes( + description: 'The merge request is attention_requested.', + value: 'attention_requested' ) ) end diff --git a/spec/graphql/types/merge_request_type_spec.rb b/spec/graphql/types/merge_request_type_spec.rb index bc3ccb0d9ba..b17b7c32289 100644 --- a/spec/graphql/types/merge_request_type_spec.rb +++ b/spec/graphql/types/merge_request_type_spec.rb @@ -18,7 +18,7 @@ RSpec.describe GitlabSchema.types['MergeRequest'] do notes discussions user_permissions id iid title title_html description 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 draft merge_when_pipeline_succeeds diff_head_sha + target_branch draft merge_when_pipeline_succeeds diff_head_sha merge_commit_sha user_notes_count user_discussions_count should_remove_source_branch diff_refs diff_stats diff_stats_summary force_remove_source_branch diff --git a/spec/graphql/types/mutation_type_spec.rb b/spec/graphql/types/mutation_type_spec.rb index c1a5c93c85b..95d835c88cf 100644 --- a/spec/graphql/types/mutation_type_spec.rb +++ b/spec/graphql/types/mutation_type_spec.rb @@ -3,14 +3,6 @@ require 'spec_helper' RSpec.describe Types::MutationType do - it 'is expected to have the deprecated MergeRequestSetWip' do - field = get_field('MergeRequestSetWip') - - expect(field).to be_present - expect(field.deprecation_reason).to be_present - expect(field.resolver).to eq(Mutations::MergeRequests::SetWip) - end - it 'is expected to have the MergeRequestSetDraft' do expect(described_class).to have_graphql_mutation(Mutations::MergeRequests::SetDraft) end diff --git a/spec/graphql/types/packages/helm/dependency_type_spec.rb b/spec/graphql/types/packages/helm/dependency_type_spec.rb new file mode 100644 index 00000000000..2047205275f --- /dev/null +++ b/spec/graphql/types/packages/helm/dependency_type_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['PackageHelmDependencyType'] do + it { expect(described_class.graphql_name).to eq('PackageHelmDependencyType') } + + it 'includes helm dependency fields' do + expected_fields = %w[ + name version repository condition tags enabled import_values alias + ] + + expect(described_class).to include_graphql_fields(*expected_fields) + end +end diff --git a/spec/graphql/types/packages/helm/file_metadatum_type_spec.rb b/spec/graphql/types/packages/helm/file_metadatum_type_spec.rb new file mode 100644 index 00000000000..b7bcd6213b4 --- /dev/null +++ b/spec/graphql/types/packages/helm/file_metadatum_type_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['HelmFileMetadata'] do + it { expect(described_class.graphql_name).to eq('HelmFileMetadata') } + + it 'includes helm file metadatum fields' do + expected_fields = %w[ + created_at updated_at channel metadata + ] + + expect(described_class).to include_graphql_fields(*expected_fields) + end +end diff --git a/spec/graphql/types/packages/helm/maintainer_type_spec.rb b/spec/graphql/types/packages/helm/maintainer_type_spec.rb new file mode 100644 index 00000000000..9ad51427d42 --- /dev/null +++ b/spec/graphql/types/packages/helm/maintainer_type_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['PackageHelmMaintainerType'] do + it { expect(described_class.graphql_name).to eq('PackageHelmMaintainerType') } + + it 'includes helm maintainer fields' do + expected_fields = %w[ + name email url + ] + + expect(described_class).to include_graphql_fields(*expected_fields) + end +end diff --git a/spec/graphql/types/packages/helm/metadata_type_spec.rb b/spec/graphql/types/packages/helm/metadata_type_spec.rb new file mode 100644 index 00000000000..04639450d9a --- /dev/null +++ b/spec/graphql/types/packages/helm/metadata_type_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['PackageHelmMetadataType'] do + it { expect(described_class.graphql_name).to eq('PackageHelmMetadataType') } + + it 'includes helm json fields' do + expected_fields = %w[ + name home sources version description keywords maintainers icon apiVersion condition tags appVersion deprecated annotations kubeVersion dependencies type + ] + + expect(described_class).to include_graphql_fields(*expected_fields) + end +end diff --git a/spec/graphql/types/project_type_spec.rb b/spec/graphql/types/project_type_spec.rb index 45a718683be..4f205e861dd 100644 --- a/spec/graphql/types/project_type_spec.rb +++ b/spec/graphql/types/project_type_spec.rb @@ -34,7 +34,7 @@ RSpec.describe GitlabSchema.types['Project'] do container_repositories container_repositories_count pipeline_analytics squash_read_only sast_ci_configuration cluster_agent cluster_agents agent_configurations - ci_template timelogs + ci_template timelogs merge_commit_template ] expect(described_class).to include_graphql_fields(*expected_fields) @@ -296,6 +296,8 @@ RSpec.describe GitlabSchema.types['Project'] do :last, :merged_after, :merged_before, + :created_after, + :created_before, :author_username, :assignee_username, :reviewer_username, diff --git a/spec/graphql/types/projects/topic_type_spec.rb b/spec/graphql/types/projects/topic_type_spec.rb new file mode 100644 index 00000000000..01c19e111be --- /dev/null +++ b/spec/graphql/types/projects/topic_type_spec.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Types::Projects::TopicType do + specify { expect(described_class.graphql_name).to eq('Topic') } + + specify do + expect(described_class).to have_graphql_fields( + :id, + :name, + :description, + :description_html, + :avatar_url + ) + end +end diff --git a/spec/graphql/types/query_type_spec.rb b/spec/graphql/types/query_type_spec.rb index 14ef03a64f9..49f0980bd08 100644 --- a/spec/graphql/types/query_type_spec.rb +++ b/spec/graphql/types/query_type_spec.rb @@ -28,6 +28,7 @@ RSpec.describe GitlabSchema.types['Query'] do runners timelogs board_list + topics ] expect(described_class).to have_graphql_fields(*expected_fields).at_least diff --git a/spec/graphql/types/release_links_type_spec.rb b/spec/graphql/types/release_links_type_spec.rb index 38c38d58baa..e77c4e3ddd1 100644 --- a/spec/graphql/types/release_links_type_spec.rb +++ b/spec/graphql/types/release_links_type_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe GitlabSchema.types['ReleaseLinks'] do - it { expect(described_class).to require_graphql_authorizations(:download_code) } + it { expect(described_class).to require_graphql_authorizations(:read_release) } it 'has the expected fields' do expected_fields = %w[ @@ -18,4 +18,46 @@ RSpec.describe GitlabSchema.types['ReleaseLinks'] do expect(described_class).to include_graphql_fields(*expected_fields) end + + context 'individual field authorization' do + def fetch_authorizations(field_name) + described_class.fields.dig(field_name).instance_variable_get(:@authorize) + end + + describe 'openedMergeRequestsUrl' do + it 'has valid authorization' do + expect(fetch_authorizations('openedMergeRequestsUrl')).to include(:download_code) + end + end + + describe 'mergedMergeRequestsUrl' do + it 'has valid authorization' do + expect(fetch_authorizations('mergedMergeRequestsUrl')).to include(:download_code) + end + end + + describe 'closedMergeRequestsUrl' do + it 'has valid authorization' do + expect(fetch_authorizations('closedMergeRequestsUrl')).to include(:download_code) + end + end + + describe 'openedIssuesUrl' do + it 'has valid authorization' do + expect(fetch_authorizations('openedIssuesUrl')).to include(:download_code) + end + end + + describe 'closedIssuesUrl' do + it 'has valid authorization' do + expect(fetch_authorizations('closedIssuesUrl')).to include(:download_code) + end + end + + describe 'editUrl' do + it 'has valid authorization' do + expect(fetch_authorizations('editUrl')).to include(:update_release) + end + end + end end diff --git a/spec/graphql/types/repository/blob_type_spec.rb b/spec/graphql/types/repository/blob_type_spec.rb index beab4dcebc2..7f37237f355 100644 --- a/spec/graphql/types/repository/blob_type_spec.rb +++ b/spec/graphql/types/repository/blob_type_spec.rb @@ -23,6 +23,7 @@ RSpec.describe Types::Repository::BlobType do :stored_externally, :raw_path, :replace_path, + :pipeline_editor_path, :simple_viewer, :rich_viewer, :plain_data, diff --git a/spec/graphql/types/user_merge_request_interaction_type_spec.rb b/spec/graphql/types/user_merge_request_interaction_type_spec.rb index f424c9200ab..1eaaa0c23d0 100644 --- a/spec/graphql/types/user_merge_request_interaction_type_spec.rb +++ b/spec/graphql/types/user_merge_request_interaction_type_spec.rb @@ -78,7 +78,7 @@ RSpec.describe GitlabSchema.types['UserMergeRequestInteraction'] do merge_request.reviewers << user end - it { is_expected.to eq(Types::MergeRequestReviewStateEnum.values['UNREVIEWED'].value) } + it { is_expected.to eq(Types::MergeRequestReviewStateEnum.values['ATTENTION_REQUESTED'].value) } it 'implies not reviewed' do expect(resolve(:reviewed)).to be false @@ -87,7 +87,8 @@ RSpec.describe GitlabSchema.types['UserMergeRequestInteraction'] do context 'when the user has provided a review' do before do - merge_request.merge_request_reviewers.create!(reviewer: user, state: MergeRequestReviewer.states['reviewed']) + reviewer = merge_request.merge_request_reviewers.create!(reviewer: user) + reviewer.update!(state: MergeRequestReviewer.states['reviewed']) end it { is_expected.to eq(Types::MergeRequestReviewStateEnum.values['REVIEWED'].value) } |