diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 14:34:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 14:34:42 +0000 |
commit | 9f46488805e86b1bc341ea1620b866016c2ce5ed (patch) | |
tree | f9748c7e287041e37d6da49e0a29c9511dc34768 /spec/graphql/types | |
parent | dfc92d081ea0332d69c8aca2f0e745cb48ae5e6d (diff) | |
download | gitlab-ce-9f46488805e86b1bc341ea1620b866016c2ce5ed.tar.gz |
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'spec/graphql/types')
67 files changed, 448 insertions, 108 deletions
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 new file mode 100644 index 00000000000..1c56028425e --- /dev/null +++ b/spec/graphql/types/alert_management/alert_status_count_type_spec.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe GitlabSchema.types['AlertManagementAlertStatusCountsType'] do + specify { expect(described_class.graphql_name).to eq('AlertManagementAlertStatusCountsType') } + + it 'exposes the expected fields' do + expected_fields = %i[ + all + open + triggered + acknowledged + resolved + ignored + ] + + expect(described_class).to have_graphql_fields(*expected_fields) + end +end diff --git a/spec/graphql/types/alert_management/alert_type_spec.rb b/spec/graphql/types/alert_management/alert_type_spec.rb new file mode 100644 index 00000000000..9c326f30e3c --- /dev/null +++ b/spec/graphql/types/alert_management/alert_type_spec.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +require 'spec_helper' + +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) } + + it 'exposes the expected fields' do + expected_fields = %i[ + iid + issue_iid + title + description + severity + status + service + monitoring_tool + hosts + started_at + ended_at + event_count + details + created_at + updated_at + ] + + expect(described_class).to have_graphql_fields(*expected_fields) + end +end diff --git a/spec/graphql/types/alert_management/severity_enum_spec.rb b/spec/graphql/types/alert_management/severity_enum_spec.rb new file mode 100644 index 00000000000..ca5aa826fe5 --- /dev/null +++ b/spec/graphql/types/alert_management/severity_enum_spec.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe GitlabSchema.types['AlertManagementSeverity'] do + specify { expect(described_class.graphql_name).to eq('AlertManagementSeverity') } + + it 'exposes all the severity values' do + expect(described_class.values.keys).to include(*%w[CRITICAL HIGH MEDIUM LOW INFO UNKNOWN]) + end +end diff --git a/spec/graphql/types/alert_management/status_enum_spec.rb b/spec/graphql/types/alert_management/status_enum_spec.rb new file mode 100644 index 00000000000..240d8863c97 --- /dev/null +++ b/spec/graphql/types/alert_management/status_enum_spec.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe GitlabSchema.types['AlertManagementStatus'] do + specify { expect(described_class.graphql_name).to eq('AlertManagementStatus') } + + describe 'statuses' do + using RSpec::Parameterized::TableSyntax + + where(:status_name, :status_value) do + 'TRIGGERED' | 0 + 'ACKNOWLEDGED' | 1 + 'RESOLVED' | 2 + 'IGNORED' | 3 + end + + with_them do + it 'exposes a status with the correct value' do + expect(described_class.values[status_name].value).to eq(status_value) + end + end + end +end 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 de5ece3b749..4e06329506d 100644 --- a/spec/graphql/types/award_emojis/award_emoji_type_spec.rb +++ b/spec/graphql/types/award_emojis/award_emoji_type_spec.rb @@ -3,9 +3,9 @@ require 'spec_helper' describe GitlabSchema.types['AwardEmoji'] do - it { expect(described_class.graphql_name).to eq('AwardEmoji') } + specify { expect(described_class.graphql_name).to eq('AwardEmoji') } - it { expect(described_class).to require_graphql_authorizations(:read_emoji) } + specify { expect(described_class).to require_graphql_authorizations(:read_emoji) } - it { expect(described_class).to have_graphql_fields(:description, :unicode_version, :emoji, :name, :unicode, :user) } + specify { expect(described_class).to have_graphql_fields(:description, :unicode_version, :emoji, :name, :unicode, :user) } end diff --git a/spec/graphql/types/blob_viewers/type_enum_spec.rb b/spec/graphql/types/blob_viewers/type_enum_spec.rb index 7bd4352f388..09664382af9 100644 --- a/spec/graphql/types/blob_viewers/type_enum_spec.rb +++ b/spec/graphql/types/blob_viewers/type_enum_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Types::BlobViewers::TypeEnum do - it { expect(described_class.graphql_name).to eq('BlobViewersType') } + specify { expect(described_class.graphql_name).to eq('BlobViewersType') } it 'exposes all tree entry types' do expect(described_class.values.keys).to include(*%w[rich simple auxiliary]) diff --git a/spec/graphql/types/board_list_type_spec.rb b/spec/graphql/types/board_list_type_spec.rb new file mode 100644 index 00000000000..69597fc9617 --- /dev/null +++ b/spec/graphql/types/board_list_type_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe GitlabSchema.types['BoardList'] do + specify { expect(described_class.graphql_name).to eq('BoardList') } + + it 'has specific fields' do + expected_fields = %w[id list_type position label] + + expect(described_class).to include_graphql_fields(*expected_fields) + end +end diff --git a/spec/graphql/types/board_type_spec.rb b/spec/graphql/types/board_type_spec.rb index 1ca4bf18b57..5d87a1757b5 100644 --- a/spec/graphql/types/board_type_spec.rb +++ b/spec/graphql/types/board_type_spec.rb @@ -3,9 +3,9 @@ require 'spec_helper' describe GitlabSchema.types['Board'] do - it { expect(described_class.graphql_name).to eq('Board') } + specify { expect(described_class.graphql_name).to eq('Board') } - it { expect(described_class).to require_graphql_authorizations(:read_board) } + specify { expect(described_class).to require_graphql_authorizations(:read_board) } it 'has specific fields' do expected_fields = %w[id name] diff --git a/spec/graphql/types/branch_type_spec.rb b/spec/graphql/types/branch_type_spec.rb new file mode 100644 index 00000000000..f58b514116d --- /dev/null +++ b/spec/graphql/types/branch_type_spec.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe GitlabSchema.types['Branch'] do + it { expect(described_class.graphql_name).to eq('Branch') } + + it { expect(described_class).to have_graphql_fields(:name, :commit) } +end diff --git a/spec/graphql/types/ci/detailed_status_type_spec.rb b/spec/graphql/types/ci/detailed_status_type_spec.rb index 169a03c770b..c62c8f23728 100644 --- a/spec/graphql/types/ci/detailed_status_type_spec.rb +++ b/spec/graphql/types/ci/detailed_status_type_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Types::Ci::DetailedStatusType do - it { expect(described_class.graphql_name).to eq('DetailedStatus') } + specify { expect(described_class.graphql_name).to eq('DetailedStatus') } it "has all fields" do expect(described_class).to have_graphql_fields(:group, :icon, :favicon, diff --git a/spec/graphql/types/ci/pipeline_type_spec.rb b/spec/graphql/types/ci/pipeline_type_spec.rb index 2fafc1bc13f..d56cff12105 100644 --- a/spec/graphql/types/ci/pipeline_type_spec.rb +++ b/spec/graphql/types/ci/pipeline_type_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Types::Ci::PipelineType do - it { expect(described_class.graphql_name).to eq('Pipeline') } + specify { expect(described_class.graphql_name).to eq('Pipeline') } - it { expect(described_class).to expose_permissions_using(Types::PermissionTypes::Ci::Pipeline) } + specify { expect(described_class).to expose_permissions_using(Types::PermissionTypes::Ci::Pipeline) } end diff --git a/spec/graphql/types/commit_type_spec.rb b/spec/graphql/types/commit_type_spec.rb index f5f99229f3a..88b450e3924 100644 --- a/spec/graphql/types/commit_type_spec.rb +++ b/spec/graphql/types/commit_type_spec.rb @@ -3,13 +3,13 @@ require 'spec_helper' describe GitlabSchema.types['Commit'] do - it { expect(described_class.graphql_name).to eq('Commit') } + specify { expect(described_class.graphql_name).to eq('Commit') } - it { expect(described_class).to require_graphql_authorizations(:download_code) } + specify { expect(described_class).to require_graphql_authorizations(:download_code) } it 'contains attributes related to commit' do expect(described_class).to have_graphql_fields( - :id, :sha, :title, :description, :message, :authored_date, + :id, :sha, :title, :description, :message, :title_html, :authored_date, :author_name, :author_gravatar, :author, :web_url, :latest_pipeline, :pipelines, :signature_html ) 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 new file mode 100644 index 00000000000..1453d73d59c --- /dev/null +++ b/spec/graphql/types/design_management/design_at_version_type_spec.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +require 'spec_helper' + +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) } + let(:object_id) do + version = design.versions.first + GitlabSchema.id_from_object(create(:design_at_version, design: design, version: version)) + end + let_it_be(:object_id_b) { GitlabSchema.id_from_object(create(:design_at_version)) } + let(:object_type) { ::Types::DesignManagement::DesignAtVersionType } + end +end diff --git a/spec/graphql/types/design_management/design_collection_type_spec.rb b/spec/graphql/types/design_management/design_collection_type_spec.rb new file mode 100644 index 00000000000..65150f0971d --- /dev/null +++ b/spec/graphql/types/design_management/design_collection_type_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe GitlabSchema.types['DesignCollection'] do + it { expect(described_class).to require_graphql_authorizations(:read_design) } + + it 'has the expected fields' do + expected_fields = %i[project issue designs versions version designAtVersion design] + + expect(described_class).to have_graphql_fields(*expected_fields) + end +end diff --git a/spec/graphql/types/design_management/design_type_spec.rb b/spec/graphql/types/design_management/design_type_spec.rb new file mode 100644 index 00000000000..75b4cd66d5e --- /dev/null +++ b/spec/graphql/types/design_management/design_type_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'spec_helper' + +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) } + let(:object_id) { GitlabSchema.id_from_object(design) } + let_it_be(:object_id_b) { GitlabSchema.id_from_object(create(:design, :with_versions)) } + let(:object_type) { ::Types::DesignManagement::DesignType } + end +end 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 new file mode 100644 index 00000000000..a65f1bb5990 --- /dev/null +++ b/spec/graphql/types/design_management/design_version_event_enum_spec.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe GitlabSchema.types['DesignVersionEvent'] do + it { expect(described_class.graphql_name).to eq('DesignVersionEvent') } + + it 'exposes the correct event states' do + expect(described_class.values.keys).to include(*%w[CREATION MODIFICATION DELETION NONE]) + end +end diff --git a/spec/graphql/types/design_management/version_type_spec.rb b/spec/graphql/types/design_management/version_type_spec.rb new file mode 100644 index 00000000000..3317c4c6571 --- /dev/null +++ b/spec/graphql/types/design_management/version_type_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe GitlabSchema.types['DesignVersion'] do + it { expect(described_class).to require_graphql_authorizations(:read_design) } + + it 'has the expected fields' do + expected_fields = %i[id sha designs design_at_version designs_at_version] + + expect(described_class).to have_graphql_fields(*expected_fields) + end +end diff --git a/spec/graphql/types/design_management_type_spec.rb b/spec/graphql/types/design_management_type_spec.rb new file mode 100644 index 00000000000..a6204f20f23 --- /dev/null +++ b/spec/graphql/types/design_management_type_spec.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +require 'spec_helper' + +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 a6ead27455f..3165e642452 100644 --- a/spec/graphql/types/diff_refs_type_spec.rb +++ b/spec/graphql/types/diff_refs_type_spec.rb @@ -3,11 +3,11 @@ require 'spec_helper' describe GitlabSchema.types['DiffRefs'] do - it { expect(described_class.graphql_name).to eq('DiffRefs') } + specify { expect(described_class.graphql_name).to eq('DiffRefs') } - it { expect(described_class).to have_graphql_fields(:head_sha, :base_sha, :start_sha).only } + specify { expect(described_class).to have_graphql_fields(:head_sha, :base_sha, :start_sha).only } - it { expect(described_class.fields['headSha'].type).to be_non_null } - it { expect(described_class.fields['baseSha'].type).not_to be_non_null } - it { expect(described_class.fields['startSha'].type).to be_non_null } + specify { expect(described_class.fields['headSha'].type).to be_non_null } + specify { expect(described_class.fields['baseSha'].type).not_to be_non_null } + specify { expect(described_class.fields['startSha'].type).to be_non_null } end diff --git a/spec/graphql/types/environment_type_spec.rb b/spec/graphql/types/environment_type_spec.rb index 24a8bddfa6a..0e5cbac05df 100644 --- a/spec/graphql/types/environment_type_spec.rb +++ b/spec/graphql/types/environment_type_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe GitlabSchema.types['Environment'] do - it { expect(described_class.graphql_name).to eq('Environment') } + specify { expect(described_class.graphql_name).to eq('Environment') } it 'has the expected fields' do expected_fields = %w[ @@ -13,5 +13,5 @@ describe GitlabSchema.types['Environment'] do expect(described_class).to have_graphql_fields(*expected_fields) end - it { expect(described_class).to require_graphql_authorizations(:read_environment) } + specify { expect(described_class).to require_graphql_authorizations(:read_environment) } end 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 44652f831b5..0a094e9e188 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 @@ -3,9 +3,9 @@ require 'spec_helper' describe GitlabSchema.types['SentryDetailedError'] do - it { expect(described_class.graphql_name).to eq('SentryDetailedError') } + specify { expect(described_class.graphql_name).to eq('SentryDetailedError') } - it { expect(described_class).to require_graphql_authorizations(:read_sentry_issue) } + specify { expect(described_class).to require_graphql_authorizations(:read_sentry_issue) } it 'exposes the expected fields' do expected_fields = %i[ 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 20ec31391d8..793da2db960 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 @@ -3,9 +3,9 @@ require 'spec_helper' describe GitlabSchema.types['SentryErrorCollection'] do - it { expect(described_class.graphql_name).to eq('SentryErrorCollection') } + specify { expect(described_class.graphql_name).to eq('SentryErrorCollection') } - it { expect(described_class).to require_graphql_authorizations(:read_sentry_issue) } + specify { expect(described_class).to require_graphql_authorizations(:read_sentry_issue) } it 'exposes the expected fields' do expected_fields = %i[ 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 05cc2ca7612..b65398fccc9 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 @@ -3,7 +3,7 @@ require 'spec_helper' describe GitlabSchema.types['SentryErrorStackTraceEntry'] do - it { expect(described_class.graphql_name).to eq('SentryErrorStackTraceEntry') } + specify { expect(described_class.graphql_name).to eq('SentryErrorStackTraceEntry') } it 'exposes the expected fields' do expected_fields = %i[ 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 2a422228f72..2cec8865764 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 @@ -3,9 +3,9 @@ require 'spec_helper' describe GitlabSchema.types['SentryErrorStackTrace'] do - it { expect(described_class.graphql_name).to eq('SentryErrorStackTrace') } + specify { expect(described_class.graphql_name).to eq('SentryErrorStackTrace') } - it { expect(described_class).to require_graphql_authorizations(:read_sentry_issue) } + specify { expect(described_class).to require_graphql_authorizations(:read_sentry_issue) } it 'exposes the expected fields' do expected_fields = %i[ 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 4676d91ef9c..f8cc801e35e 100644 --- a/spec/graphql/types/error_tracking/sentry_error_type_spec.rb +++ b/spec/graphql/types/error_tracking/sentry_error_type_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe GitlabSchema.types['SentryError'] do - it { expect(described_class.graphql_name).to eq('SentryError') } + specify { expect(described_class.graphql_name).to eq('SentryError') } it 'exposes the expected fields' do expected_fields = %i[ diff --git a/spec/graphql/types/grafana_integration_type_spec.rb b/spec/graphql/types/grafana_integration_type_spec.rb index ac26911acbf..429b5bdffe6 100644 --- a/spec/graphql/types/grafana_integration_type_spec.rb +++ b/spec/graphql/types/grafana_integration_type_spec.rb @@ -14,9 +14,9 @@ describe GitlabSchema.types['GrafanaIntegration'] do ] end - it { expect(described_class.graphql_name).to eq('GrafanaIntegration') } + specify { expect(described_class.graphql_name).to eq('GrafanaIntegration') } - it { expect(described_class).to require_graphql_authorizations(:admin_operations) } + specify { expect(described_class).to require_graphql_authorizations(:admin_operations) } - it { expect(described_class).to have_graphql_fields(*expected_fields) } + specify { expect(described_class).to have_graphql_fields(*expected_fields) } end diff --git a/spec/graphql/types/group_type_spec.rb b/spec/graphql/types/group_type_spec.rb index 532f1a4b53d..a834a9038db 100644 --- a/spec/graphql/types/group_type_spec.rb +++ b/spec/graphql/types/group_type_spec.rb @@ -3,11 +3,11 @@ require 'spec_helper' describe GitlabSchema.types['Group'] do - it { expect(described_class).to expose_permissions_using(Types::PermissionTypes::Group) } + specify { expect(described_class).to expose_permissions_using(Types::PermissionTypes::Group) } - it { expect(described_class.graphql_name).to eq('Group') } + specify { expect(described_class.graphql_name).to eq('Group') } - it { expect(described_class).to require_graphql_authorizations(:read_group) } + specify { expect(described_class).to require_graphql_authorizations(:read_group) } it 'has the expected fields' do expected_fields = %w[ diff --git a/spec/graphql/types/issuable_sort_enum_spec.rb b/spec/graphql/types/issuable_sort_enum_spec.rb new file mode 100644 index 00000000000..35c42d8194c --- /dev/null +++ b/spec/graphql/types/issuable_sort_enum_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Types::IssuableSortEnum do + specify { expect(described_class.graphql_name).to eq('IssuableSort') } + + it 'exposes all the existing issuable sort values' do + expect(described_class.values.keys).to include( + *%w[PRIORITY_ASC PRIORITY_DESC + LABEL_PRIORITY_ASC LABEL_PRIORITY_DESC + MILESTONE_DUE_ASC MILESTONE_DUE_DESC] + ) + end +end diff --git a/spec/graphql/types/issuable_state_enum_spec.rb b/spec/graphql/types/issuable_state_enum_spec.rb index 65a80fa4176..f974ed5f5fb 100644 --- a/spec/graphql/types/issuable_state_enum_spec.rb +++ b/spec/graphql/types/issuable_state_enum_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe GitlabSchema.types['IssuableState'] do - it { expect(described_class.graphql_name).to eq('IssuableState') } + specify { expect(described_class.graphql_name).to eq('IssuableState') } it_behaves_like 'issuable state' end diff --git a/spec/graphql/types/issue_sort_enum_spec.rb b/spec/graphql/types/issue_sort_enum_spec.rb index 1b6aa6d6069..c496b897cdb 100644 --- a/spec/graphql/types/issue_sort_enum_spec.rb +++ b/spec/graphql/types/issue_sort_enum_spec.rb @@ -3,11 +3,13 @@ require 'spec_helper' describe GitlabSchema.types['IssueSort'] do - it { expect(described_class.graphql_name).to eq('IssueSort') } + specify { expect(described_class.graphql_name).to eq('IssueSort') } it_behaves_like 'common sort values' it 'exposes all the existing issue sort values' do - expect(described_class.values.keys).to include(*%w[DUE_DATE_ASC DUE_DATE_DESC RELATIVE_POSITION_ASC]) + expect(described_class.values.keys).to include( + *%w[DUE_DATE_ASC DUE_DATE_DESC RELATIVE_POSITION_ASC] + ) end end diff --git a/spec/graphql/types/issue_state_enum_spec.rb b/spec/graphql/types/issue_state_enum_spec.rb index de19e6fc505..a18c5f5d317 100644 --- a/spec/graphql/types/issue_state_enum_spec.rb +++ b/spec/graphql/types/issue_state_enum_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe GitlabSchema.types['IssueState'] do - it { expect(described_class.graphql_name).to eq('IssueState') } + specify { expect(described_class.graphql_name).to eq('IssueState') } it_behaves_like 'issuable state' end diff --git a/spec/graphql/types/issue_type_spec.rb b/spec/graphql/types/issue_type_spec.rb index ebe48c17c11..a8f7edcfe8e 100644 --- a/spec/graphql/types/issue_type_spec.rb +++ b/spec/graphql/types/issue_type_spec.rb @@ -3,18 +3,19 @@ require 'spec_helper' describe GitlabSchema.types['Issue'] do - it { expect(described_class).to expose_permissions_using(Types::PermissionTypes::Issue) } + specify { expect(described_class).to expose_permissions_using(Types::PermissionTypes::Issue) } - it { expect(described_class.graphql_name).to eq('Issue') } + specify { expect(described_class.graphql_name).to eq('Issue') } - it { expect(described_class).to require_graphql_authorizations(:read_issue) } + specify { expect(described_class).to require_graphql_authorizations(:read_issue) } - it { expect(described_class.interfaces).to include(Types::Notes::NoteableType) } + 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 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] + subscribed time_estimate total_time_spent closed_at created_at updated_at task_completion_status + designs design_collection] fields.each do |field_name| expect(described_class).to have_graphql_field(field_name) diff --git a/spec/graphql/types/jira_import_type_spec.rb b/spec/graphql/types/jira_import_type_spec.rb index 8448a120682..ac1aa672e30 100644 --- a/spec/graphql/types/jira_import_type_spec.rb +++ b/spec/graphql/types/jira_import_type_spec.rb @@ -3,9 +3,9 @@ require 'spec_helper' describe GitlabSchema.types['JiraImport'] do - it { expect(described_class.graphql_name).to eq('JiraImport') } + specify { expect(described_class.graphql_name).to eq('JiraImport') } it 'has the expected fields' do - expect(described_class).to have_graphql_fields(:jira_project_key, :scheduled_at, :scheduled_by) + expect(described_class).to have_graphql_fields(:jira_project_key, :createdAt, :scheduled_at, :scheduled_by) end end diff --git a/spec/graphql/types/label_type_spec.rb b/spec/graphql/types/label_type_spec.rb index 71b86d9b528..026c63906ef 100644 --- a/spec/graphql/types/label_type_spec.rb +++ b/spec/graphql/types/label_type_spec.rb @@ -8,5 +8,5 @@ describe GitlabSchema.types['Label'] do expect(described_class).to have_graphql_fields(*expected_fields) end - it { expect(described_class).to require_graphql_authorizations(:read_label) } + specify { expect(described_class).to require_graphql_authorizations(:read_label) } end diff --git a/spec/graphql/types/merge_request_state_enum_spec.rb b/spec/graphql/types/merge_request_state_enum_spec.rb index 626e33b18d3..2abc7b298b1 100644 --- a/spec/graphql/types/merge_request_state_enum_spec.rb +++ b/spec/graphql/types/merge_request_state_enum_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe GitlabSchema.types['MergeRequestState'] do - it { expect(described_class.graphql_name).to eq('MergeRequestState') } + 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 0c83ebd3de9..e7ab2100084 100644 --- a/spec/graphql/types/merge_request_type_spec.rb +++ b/spec/graphql/types/merge_request_type_spec.rb @@ -3,11 +3,11 @@ require 'spec_helper' describe GitlabSchema.types['MergeRequest'] do - it { expect(described_class).to expose_permissions_using(Types::PermissionTypes::MergeRequest) } + specify { expect(described_class).to expose_permissions_using(Types::PermissionTypes::MergeRequest) } - it { expect(described_class).to require_graphql_authorizations(:read_merge_request) } + specify { expect(described_class).to require_graphql_authorizations(:read_merge_request) } - it { expect(described_class.interfaces).to include(Types::Notes::NoteableType) } + specify { expect(described_class.interfaces).to include(Types::Notes::NoteableType) } it 'has the expected fields' do expected_fields = %w[ diff --git a/spec/graphql/types/metadata_type_spec.rb b/spec/graphql/types/metadata_type_spec.rb index c8270a8c2f5..75369ec9c3c 100644 --- a/spec/graphql/types/metadata_type_spec.rb +++ b/spec/graphql/types/metadata_type_spec.rb @@ -3,6 +3,6 @@ require 'spec_helper' describe GitlabSchema.types['Metadata'] do - it { expect(described_class.graphql_name).to eq('Metadata') } - it { expect(described_class).to require_graphql_authorizations(:read_instance_metadata) } + 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 76f2b4b8935..81219c596a7 100644 --- a/spec/graphql/types/metrics/dashboard_type_spec.rb +++ b/spec/graphql/types/metrics/dashboard_type_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe GitlabSchema.types['MetricsDashboard'] do - it { expect(described_class.graphql_name).to eq('MetricsDashboard') } + specify { expect(described_class.graphql_name).to eq('MetricsDashboard') } it 'has the expected fields' do expected_fields = %w[ diff --git a/spec/graphql/types/metrics/dashboards/annotation_type_spec.rb b/spec/graphql/types/metrics/dashboards/annotation_type_spec.rb index 2956a2512eb..dbb8b04dbd7 100644 --- a/spec/graphql/types/metrics/dashboards/annotation_type_spec.rb +++ b/spec/graphql/types/metrics/dashboards/annotation_type_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe GitlabSchema.types['MetricsDashboardAnnotation'] do - it { expect(described_class.graphql_name).to eq('MetricsDashboardAnnotation') } + specify { expect(described_class.graphql_name).to eq('MetricsDashboardAnnotation') } it 'has the expected fields' do expected_fields = %w[ @@ -13,5 +13,5 @@ describe GitlabSchema.types['MetricsDashboardAnnotation'] do expect(described_class).to have_graphql_fields(*expected_fields) end - it { expect(described_class).to require_graphql_authorizations(:read_metrics_dashboard_annotation) } + specify { expect(described_class).to require_graphql_authorizations(:read_metrics_dashboard_annotation) } end diff --git a/spec/graphql/types/milestone_type_spec.rb b/spec/graphql/types/milestone_type_spec.rb index f7ee79eae9f..4c3d9f50a64 100644 --- a/spec/graphql/types/milestone_type_spec.rb +++ b/spec/graphql/types/milestone_type_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe GitlabSchema.types['Milestone'] do - it { expect(described_class.graphql_name).to eq('Milestone') } + specify { expect(described_class.graphql_name).to eq('Milestone') } - it { expect(described_class).to require_graphql_authorizations(:read_milestone) } + specify { expect(described_class).to require_graphql_authorizations(:read_milestone) } end diff --git a/spec/graphql/types/namespace_type_spec.rb b/spec/graphql/types/namespace_type_spec.rb index 6c2ba70cf4c..741698021e7 100644 --- a/spec/graphql/types/namespace_type_spec.rb +++ b/spec/graphql/types/namespace_type_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe GitlabSchema.types['Namespace'] do - it { expect(described_class.graphql_name).to eq('Namespace') } + specify { expect(described_class.graphql_name).to eq('Namespace') } it 'has the expected fields' do expected_fields = %w[ @@ -14,5 +14,5 @@ describe GitlabSchema.types['Namespace'] do expect(described_class).to have_graphql_fields(*expected_fields) end - it { expect(described_class).to require_graphql_authorizations(:read_namespace) } + specify { expect(described_class).to require_graphql_authorizations(:read_namespace) } end diff --git a/spec/graphql/types/notes/discussion_type_spec.rb b/spec/graphql/types/notes/discussion_type_spec.rb index 804785ba67d..44774594d17 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 - it { expect(described_class).to have_graphql_fields(:id, :created_at, :notes, :reply_id) } + specify { expect(described_class).to have_graphql_fields(:id, :created_at, :notes, :reply_id) } - it { expect(described_class).to require_graphql_authorizations(:read_note) } + specify { expect(described_class).to require_graphql_authorizations(:read_note) } end diff --git a/spec/graphql/types/notes/note_type_spec.rb b/spec/graphql/types/notes/note_type_spec.rb index 8cf84cd8dfd..019f742ee77 100644 --- a/spec/graphql/types/notes/note_type_spec.rb +++ b/spec/graphql/types/notes/note_type_spec.rb @@ -10,6 +10,6 @@ describe GitlabSchema.types['Note'] do expect(described_class).to have_graphql_fields(*expected_fields) end - it { expect(described_class).to expose_permissions_using(Types::PermissionTypes::Note) } - it { expect(described_class).to require_graphql_authorizations(:read_note) } + specify { expect(described_class).to expose_permissions_using(Types::PermissionTypes::Note) } + specify { expect(described_class).to require_graphql_authorizations(:read_note) } end diff --git a/spec/graphql/types/notes/noteable_type_spec.rb b/spec/graphql/types/notes/noteable_type_spec.rb index a4259e160e0..4a81f45bd4e 100644 --- a/spec/graphql/types/notes/noteable_type_spec.rb +++ b/spec/graphql/types/notes/noteable_type_spec.rb @@ -2,12 +2,13 @@ require 'spec_helper' describe Types::Notes::NoteableType do - it { expect(described_class).to have_graphql_fields(:notes, :discussions) } + specify { expect(described_class).to have_graphql_fields(:notes, :discussions) } describe ".resolve_type" do it 'knows the correct type for objects' do expect(described_class.resolve_type(build(:issue), {})).to eq(Types::IssueType) expect(described_class.resolve_type(build(:merge_request), {})).to eq(Types::MergeRequestType) + expect(described_class.resolve_type(build(:design), {})).to eq(Types::DesignManagement::DesignType) end end end diff --git a/spec/graphql/types/permission_types/issue_spec.rb b/spec/graphql/types/permission_types/issue_spec.rb index a94bc6b780e..a7a3dd00f11 100644 --- a/spec/graphql/types/permission_types/issue_spec.rb +++ b/spec/graphql/types/permission_types/issue_spec.rb @@ -5,8 +5,9 @@ require 'spec_helper' describe Types::PermissionTypes::Issue do it do expected_permissions = [ - :read_issue, :admin_issue, :update_issue, - :create_note, :reopen_issue + :read_issue, :admin_issue, :update_issue, :reopen_issue, + :read_design, :create_design, :destroy_design, + :create_note ] expected_permissions.each do |permission| 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 572b4ac42d0..7e9752cdc46 100644 --- a/spec/graphql/types/permission_types/merge_request_type_spec.rb +++ b/spec/graphql/types/permission_types/merge_request_type_spec.rb @@ -3,5 +3,5 @@ require 'spec_helper' describe Types::MergeRequestType do - it { expect(described_class).to expose_permissions_using(Types::PermissionTypes::MergeRequest) } + specify { expect(described_class).to expose_permissions_using(Types::PermissionTypes::MergeRequest) } end diff --git a/spec/graphql/types/permission_types/project_spec.rb b/spec/graphql/types/permission_types/project_spec.rb index 56c4c2de4df..2789464d29c 100644 --- a/spec/graphql/types/permission_types/project_spec.rb +++ b/spec/graphql/types/permission_types/project_spec.rb @@ -13,7 +13,7 @@ describe Types::PermissionTypes::Project do :create_merge_request_from, :create_wiki, :push_code, :create_deployment, :push_to_delete_protected_branch, :admin_wiki, :admin_project, :update_pages, :admin_remote_mirror, :create_label, :update_wiki, :destroy_wiki, :create_pages, :destroy_pages, :read_pages_content, - :read_merge_request + :read_merge_request, :read_design, :create_design, :destroy_design ] expected_permissions.each do |permission| diff --git a/spec/graphql/types/project_type_spec.rb b/spec/graphql/types/project_type_spec.rb index 6ea852190c9..6368f743720 100644 --- a/spec/graphql/types/project_type_spec.rb +++ b/spec/graphql/types/project_type_spec.rb @@ -3,11 +3,11 @@ require 'spec_helper' describe GitlabSchema.types['Project'] do - it { expect(described_class).to expose_permissions_using(Types::PermissionTypes::Project) } + specify { expect(described_class).to expose_permissions_using(Types::PermissionTypes::Project) } - it { expect(described_class.graphql_name).to eq('Project') } + specify { expect(described_class.graphql_name).to eq('Project') } - it { expect(described_class).to require_graphql_authorizations(:read_project) } + specify { expect(described_class).to require_graphql_authorizations(:read_project) } it 'has the expected fields' do expected_fields = %w[ @@ -24,7 +24,8 @@ describe GitlabSchema.types['Project'] do namespace group statistics repository merge_requests merge_request issues issue pipelines removeSourceBranchAfterMerge sentryDetailedError snippets grafanaIntegration autocloseReferencedIssues suggestion_commit_message environments - boards jira_import_status jira_imports services + boards jira_import_status jira_imports services releases release + alert_management_alerts alert_management_alert alert_management_alert_status_counts ] expect(described_class).to include_graphql_fields(*expected_fields) @@ -96,4 +97,18 @@ describe GitlabSchema.types['Project'] do it { is_expected.to have_graphql_type(Types::Projects::ServiceType.connection_type) } end + + describe 'releases field' do + subject { described_class.fields['release'] } + + it { is_expected.to have_graphql_type(Types::ReleaseType) } + it { is_expected.to have_graphql_resolver(Resolvers::ReleaseResolver) } + end + + describe 'release field' do + subject { described_class.fields['releases'] } + + it { is_expected.to have_graphql_type(Types::ReleaseType.connection_type) } + it { is_expected.to have_graphql_resolver(Resolvers::ReleasesResolver) } + end end diff --git a/spec/graphql/types/projects/base_service_type_spec.rb b/spec/graphql/types/projects/base_service_type_spec.rb index bda6022bf79..4fcb9fe1a73 100644 --- a/spec/graphql/types/projects/base_service_type_spec.rb +++ b/spec/graphql/types/projects/base_service_type_spec.rb @@ -3,11 +3,11 @@ require 'spec_helper' describe GitlabSchema.types['BaseService'] do - it { expect(described_class.graphql_name).to eq('BaseService') } + specify { expect(described_class.graphql_name).to eq('BaseService') } it 'has basic expected fields' do expect(described_class).to have_graphql_fields(:type, :active) end - it { expect(described_class).to require_graphql_authorizations(:admin_project) } + specify { expect(described_class).to require_graphql_authorizations(:admin_project) } end diff --git a/spec/graphql/types/projects/jira_service_type_spec.rb b/spec/graphql/types/projects/jira_service_type_spec.rb index 7f8fa6538e9..91d7e4586cb 100644 --- a/spec/graphql/types/projects/jira_service_type_spec.rb +++ b/spec/graphql/types/projects/jira_service_type_spec.rb @@ -3,11 +3,11 @@ require 'spec_helper' describe GitlabSchema.types['JiraService'] do - it { expect(described_class.graphql_name).to eq('JiraService') } + specify { expect(described_class.graphql_name).to eq('JiraService') } it 'has basic expected fields' do expect(described_class).to have_graphql_fields(:type, :active) end - it { expect(described_class).to require_graphql_authorizations(:admin_project) } + specify { expect(described_class).to require_graphql_authorizations(:admin_project) } end diff --git a/spec/graphql/types/projects/service_type_spec.rb b/spec/graphql/types/projects/service_type_spec.rb index ad30a4008bc..f6758d17d18 100644 --- a/spec/graphql/types/projects/service_type_spec.rb +++ b/spec/graphql/types/projects/service_type_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Types::Projects::ServiceType do - it { expect(described_class).to have_graphql_fields(:type, :active) } + specify { expect(described_class).to have_graphql_fields(:type, :active) } describe ".resolve_type" do it 'resolves the corresponding type for objects' do diff --git a/spec/graphql/types/projects/services_enum_spec.rb b/spec/graphql/types/projects/services_enum_spec.rb index aac4aae4f69..91e398e8d81 100644 --- a/spec/graphql/types/projects/services_enum_spec.rb +++ b/spec/graphql/types/projects/services_enum_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe GitlabSchema.types['ServiceType'] do - it { expect(described_class.graphql_name).to eq('ServiceType') } + specify { expect(described_class.graphql_name).to eq('ServiceType') } it 'exposes all the existing project services' do expect(described_class.values.keys).to match_array(available_services_enum) diff --git a/spec/graphql/types/query_type_spec.rb b/spec/graphql/types/query_type_spec.rb index ab210f2e918..1f269a80d00 100644 --- a/spec/graphql/types/query_type_spec.rb +++ b/spec/graphql/types/query_type_spec.rb @@ -8,7 +8,7 @@ describe GitlabSchema.types['Query'] do end it 'has the expected fields' do - expected_fields = %i[project namespace group echo metadata current_user snippets] + expected_fields = %i[project namespace group echo metadata current_user snippets design_management] expect(described_class).to have_graphql_fields(*expected_fields).at_least end diff --git a/spec/graphql/types/release_type_spec.rb b/spec/graphql/types/release_type_spec.rb new file mode 100644 index 00000000000..d22a0b4f0fa --- /dev/null +++ b/spec/graphql/types/release_type_spec.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +require 'spec_helper' + +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 milestones author commit + created_at released_at + ] + + expect(described_class).to include_graphql_fields(*expected_fields) + end + + describe 'milestones field' do + subject { described_class.fields['milestones'] } + + it { is_expected.to have_graphql_type(Types::MilestoneType.connection_type) } + end + + describe 'author field' do + subject { described_class.fields['author'] } + + it { is_expected.to have_graphql_type(Types::UserType) } + end + + describe 'commit field' 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 f746e75b574..fb52839c712 100644 --- a/spec/graphql/types/repository_type_spec.rb +++ b/spec/graphql/types/repository_type_spec.rb @@ -3,11 +3,11 @@ require 'spec_helper' describe GitlabSchema.types['Repository'] do - it { expect(described_class.graphql_name).to eq('Repository') } + specify { expect(described_class.graphql_name).to eq('Repository') } - it { expect(described_class).to require_graphql_authorizations(:download_code) } + specify { expect(described_class).to require_graphql_authorizations(:download_code) } - it { expect(described_class).to have_graphql_field(:root_ref) } + specify { expect(described_class).to have_graphql_field(:root_ref) } - it { expect(described_class).to have_graphql_field(:tree) } + specify { expect(described_class).to have_graphql_field(:tree) } end diff --git a/spec/graphql/types/root_storage_statistics_type_spec.rb b/spec/graphql/types/root_storage_statistics_type_spec.rb index b796b974b82..ebaa5a18623 100644 --- a/spec/graphql/types/root_storage_statistics_type_spec.rb +++ b/spec/graphql/types/root_storage_statistics_type_spec.rb @@ -3,12 +3,12 @@ require 'spec_helper' describe GitlabSchema.types['RootStorageStatistics'] do - it { expect(described_class.graphql_name).to eq('RootStorageStatistics') } + 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) end - it { expect(described_class).to require_graphql_authorizations(:read_statistics) } + specify { expect(described_class).to require_graphql_authorizations(:read_statistics) } end diff --git a/spec/graphql/types/snippet_type_spec.rb b/spec/graphql/types/snippet_type_spec.rb index 6e580711fda..adc13d4d651 100644 --- a/spec/graphql/types/snippet_type_spec.rb +++ b/spec/graphql/types/snippet_type_spec.rb @@ -17,7 +17,7 @@ describe GitlabSchema.types['Snippet'] do end describe 'authorizations' do - it { expect(described_class).to require_graphql_authorizations(:read_snippet) } + specify { expect(described_class).to require_graphql_authorizations(:read_snippet) } end shared_examples 'response without repository URLs' do @@ -35,14 +35,6 @@ describe GitlabSchema.types['Snippet'] do expect(response['sshUrlToRepo']).to eq(snippet.ssh_url_to_repo) expect(response['httpUrlToRepo']).to eq(snippet.http_url_to_repo) end - - context 'when version_snippets feature is disabled' do - before do - stub_feature_flags(version_snippets: false) - end - - it_behaves_like 'response without repository URLs' - end end end diff --git a/spec/graphql/types/snippets/blob_type_spec.rb b/spec/graphql/types/snippets/blob_type_spec.rb index da36ab80f44..fb8c6896732 100644 --- a/spec/graphql/types/snippets/blob_type_spec.rb +++ b/spec/graphql/types/snippets/blob_type_spec.rb @@ -6,8 +6,22 @@ describe GitlabSchema.types['SnippetBlob'] do it 'has the correct fields' do expected_fields = [:rich_data, :plain_data, :raw_path, :size, :binary, :name, :path, - :simple_viewer, :rich_viewer, :mode] + :simple_viewer, :rich_viewer, :mode, :external_storage, + :rendered_as_text] expect(described_class).to have_graphql_fields(*expected_fields) end + + specify { expect(described_class.fields['richData'].type).not_to be_non_null } + specify { expect(described_class.fields['plainData'].type).not_to be_non_null } + specify { expect(described_class.fields['rawPath'].type).to be_non_null } + specify { expect(described_class.fields['size'].type).to be_non_null } + specify { expect(described_class.fields['binary'].type).to be_non_null } + specify { expect(described_class.fields['name'].type).not_to be_non_null } + specify { expect(described_class.fields['path'].type).not_to be_non_null } + specify { expect(described_class.fields['simpleViewer'].type).to be_non_null } + specify { expect(described_class.fields['richViewer'].type).not_to be_non_null } + specify { expect(described_class.fields['mode'].type).not_to be_non_null } + specify { expect(described_class.fields['externalStorage'].type).not_to be_non_null } + specify { expect(described_class.fields['renderedAsText'].type).to be_non_null } end diff --git a/spec/graphql/types/snippets/blob_viewer_type_spec.rb b/spec/graphql/types/snippets/blob_viewer_type_spec.rb index a51d09813ab..841e22451db 100644 --- a/spec/graphql/types/snippets/blob_viewer_type_spec.rb +++ b/spec/graphql/types/snippets/blob_viewer_type_spec.rb @@ -3,10 +3,91 @@ require 'spec_helper' 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') } + it 'has the correct fields' do expected_fields = [:type, :load_async, :too_large, :collapsed, :render_error, :file_type, :loading_partial_name] expect(described_class).to have_graphql_fields(*expected_fields) end + + it { expect(described_class.fields['type'].type).to be_non_null } + it { expect(described_class.fields['loadAsync'].type).to be_non_null } + it { expect(described_class.fields['collapsed'].type).to be_non_null } + it { expect(described_class.fields['tooLarge'].type).to be_non_null } + it { expect(described_class.fields['renderError'].type).not_to be_non_null } + it { expect(described_class.fields['fileType'].type).to be_non_null } + it { expect(described_class.fields['loadingPartialName'].type).to be_non_null } + + shared_examples 'nil field converted to false' do + subject { GitlabSchema.execute(query, context: { current_user: snippet.author }).as_json } + + before do + allow_next_instance_of(SnippetPresenter) do |instance| + allow(instance).to receive(:blob).and_return(blob) + end + end + + it 'returns false' do + snippet_blob = subject.dig('data', 'snippets', 'edges')[0].dig('node', 'blob') + + expect(snippet_blob['path']).to eq blob.path + expect(blob_attribute).to be_nil + expect(snippet_blob['simpleViewer'][attribute]).to eq false + end + end + + describe 'collapsed' do + it_behaves_like 'nil field converted to false' do + let(:query) do + %( + query { + snippets(ids:"#{snippet.to_global_id}"){ + edges { + node { + blob { + path + simpleViewer { + collapsed + } + } + } + } + } + } + ) + end + + let(:attribute) { 'collapsed' } + let(:blob_attribute) { blob.simple_viewer.collapsed? } + end + end + + describe 'tooLarge' do + it_behaves_like 'nil field converted to false' do + let(:query) do + %( + query { + snippets(ids:"#{snippet.to_global_id}"){ + edges { + node { + blob { + path + simpleViewer { + tooLarge + } + } + } + } + } + } + ) + end + + let(:attribute) { 'tooLarge' } + let(:blob_attribute) { blob.simple_viewer.too_large? } + end + end end diff --git a/spec/graphql/types/time_type_spec.rb b/spec/graphql/types/time_type_spec.rb index 88a535ed3bb..3c6e191e2fb 100644 --- a/spec/graphql/types/time_type_spec.rb +++ b/spec/graphql/types/time_type_spec.rb @@ -6,7 +6,7 @@ describe GitlabSchema.types['Time'] do let(:iso) { "2018-06-04T15:23:50+02:00" } let(:time) { Time.parse(iso) } - it { expect(described_class.graphql_name).to eq('Time') } + specify { expect(described_class.graphql_name).to eq('Time') } it 'coerces Time object into ISO 8601' do expect(described_class.coerce_isolated_result(time)).to eq(iso) diff --git a/spec/graphql/types/todo_type_spec.rb b/spec/graphql/types/todo_type_spec.rb index 59118259d09..87a5405f0e2 100644 --- a/spec/graphql/types/todo_type_spec.rb +++ b/spec/graphql/types/todo_type_spec.rb @@ -9,5 +9,5 @@ describe GitlabSchema.types['Todo'] do expect(described_class).to have_graphql_fields(*expected_fields) end - it { expect(described_class).to require_graphql_authorizations(:read_todo) } + specify { expect(described_class).to require_graphql_authorizations(:read_todo) } end diff --git a/spec/graphql/types/tree/blob_type_spec.rb b/spec/graphql/types/tree/blob_type_spec.rb index 516c862b9c6..547a03b5edf 100644 --- a/spec/graphql/types/tree/blob_type_spec.rb +++ b/spec/graphql/types/tree/blob_type_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Types::Tree::BlobType do - it { expect(described_class.graphql_name).to eq('Blob') } + specify { expect(described_class.graphql_name).to eq('Blob') } - it { 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) } end diff --git a/spec/graphql/types/tree/submodule_type_spec.rb b/spec/graphql/types/tree/submodule_type_spec.rb index 81f7ad825a1..b5cfe8eb812 100644 --- a/spec/graphql/types/tree/submodule_type_spec.rb +++ b/spec/graphql/types/tree/submodule_type_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Types::Tree::SubmoduleType do - it { expect(described_class.graphql_name).to eq('Submodule') } + specify { expect(described_class.graphql_name).to eq('Submodule') } - it { expect(described_class).to have_graphql_fields(:id, :sha, :name, :type, :path, :flat_path, :web_url, :tree_url) } + specify { expect(described_class).to have_graphql_fields(:id, :sha, :name, :type, :path, :flat_path, :web_url, :tree_url) } end diff --git a/spec/graphql/types/tree/tree_entry_type_spec.rb b/spec/graphql/types/tree/tree_entry_type_spec.rb index 228a4be0949..14826d06645 100644 --- a/spec/graphql/types/tree/tree_entry_type_spec.rb +++ b/spec/graphql/types/tree/tree_entry_type_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Types::Tree::TreeEntryType do - it { expect(described_class.graphql_name).to eq('TreeEntry') } + specify { expect(described_class.graphql_name).to eq('TreeEntry') } - it { expect(described_class).to have_graphql_fields(:id, :sha, :name, :type, :path, :flat_path, :web_url) } + specify { expect(described_class).to have_graphql_fields(:id, :sha, :name, :type, :path, :flat_path, :web_url) } end diff --git a/spec/graphql/types/tree/tree_type_spec.rb b/spec/graphql/types/tree/tree_type_spec.rb index 23779d75600..93faebd3602 100644 --- a/spec/graphql/types/tree/tree_type_spec.rb +++ b/spec/graphql/types/tree/tree_type_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Types::Tree::TreeType do - it { expect(described_class.graphql_name).to eq('Tree') } + specify { expect(described_class.graphql_name).to eq('Tree') } - it { expect(described_class).to have_graphql_fields(:trees, :submodules, :blobs, :last_commit) } + specify { expect(described_class).to have_graphql_fields(:trees, :submodules, :blobs, :last_commit) } end diff --git a/spec/graphql/types/tree/type_enum_spec.rb b/spec/graphql/types/tree/type_enum_spec.rb index 4caf9e1c457..dcacd6073f9 100644 --- a/spec/graphql/types/tree/type_enum_spec.rb +++ b/spec/graphql/types/tree/type_enum_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Types::Tree::TypeEnum do - it { expect(described_class.graphql_name).to eq('EntryType') } + specify { expect(described_class.graphql_name).to eq('EntryType') } it 'exposes all tree entry types' do expect(described_class.values.keys).to include(*%w[tree blob commit]) diff --git a/spec/graphql/types/user_type_spec.rb b/spec/graphql/types/user_type_spec.rb index 8c76ce43e95..cf1e91afb80 100644 --- a/spec/graphql/types/user_type_spec.rb +++ b/spec/graphql/types/user_type_spec.rb @@ -3,13 +3,13 @@ require 'spec_helper' describe GitlabSchema.types['User'] do - it { expect(described_class.graphql_name).to eq('User') } + specify { expect(described_class.graphql_name).to eq('User') } - it { expect(described_class).to require_graphql_authorizations(:read_user) } + specify { expect(described_class).to require_graphql_authorizations(:read_user) } it 'has the expected fields' do expected_fields = %w[ - user_permissions snippets name username avatarUrl webUrl todos + id user_permissions snippets name username avatarUrl webUrl todos state ] expect(described_class).to have_graphql_fields(*expected_fields) |