diff options
Diffstat (limited to 'spec/graphql')
24 files changed, 386 insertions, 53 deletions
diff --git a/spec/graphql/mutations/achievements/create_spec.rb b/spec/graphql/mutations/achievements/create_spec.rb new file mode 100644 index 00000000000..4bad6164314 --- /dev/null +++ b/spec/graphql/mutations/achievements/create_spec.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Mutations::Achievements::Create, feature_category: :users do + include GraphqlHelpers + + let_it_be(:user) { create(:user) } + + let(:group) { create(:group) } + let(:valid_params) do + attributes_for(:achievement, namespace: group) + end + + describe '#resolve' do + subject(:resolve_mutation) do + described_class.new(object: nil, context: { current_user: user }, field: nil).resolve( + **valid_params, + namespace_id: group.to_global_id + ) + end + + context 'when the user does not have permission' do + before do + group.add_developer(user) + end + + it 'raises an error' do + expect { resolve_mutation }.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable) + .with_message(Gitlab::Graphql::Authorize::AuthorizeResource::RESOURCE_ACCESS_ERROR) + end + end + + context 'when the user has permission' do + before do + group.add_maintainer(user) + end + + context 'when the params are invalid' do + it 'returns the validation error' do + valid_params[:name] = nil + + expect(resolve_mutation[:errors]).to match_array(["Name can't be blank"]) + end + end + + it 'creates contact with correct values' do + expect(resolve_mutation[:achievement]).to have_attributes(valid_params) + end + end + end + + specify { expect(described_class).to require_graphql_authorizations(:admin_achievement) } +end diff --git a/spec/graphql/resolvers/ci/jobs_resolver_spec.rb b/spec/graphql/resolvers/ci/jobs_resolver_spec.rb index 80a70938dc4..581652a8cea 100644 --- a/spec/graphql/resolvers/ci/jobs_resolver_spec.rb +++ b/spec/graphql/resolvers/ci/jobs_resolver_spec.rb @@ -59,5 +59,18 @@ RSpec.describe Resolvers::Ci::JobsResolver do ) end end + + context 'when a job is manual' do + before_all do + create(:ci_build, name: 'Manual job', pipeline: pipeline, when: 'manual') + end + + it "returns jobs with when set to 'manual'" do + jobs = resolve(described_class, obj: pipeline, arg_style: :internal, args: { when_executed: ['manual'] }) + expect(jobs).to contain_exactly( + have_attributes(name: 'Manual job') + ) + end + end end end diff --git a/spec/graphql/resolvers/timelog_resolver_spec.rb b/spec/graphql/resolvers/timelog_resolver_spec.rb index da2747fdf72..cd52308d895 100644 --- a/spec/graphql/resolvers/timelog_resolver_spec.rb +++ b/spec/graphql/resolvers/timelog_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Resolvers::TimelogResolver do +RSpec.describe Resolvers::TimelogResolver, feature_category: :team_planning do include GraphqlHelpers let_it_be(:current_user) { create(:user) } @@ -262,18 +262,6 @@ RSpec.describe Resolvers::TimelogResolver do it_behaves_like 'with a user' end - context 'when > `default_max_page_size` records' do - let(:object) { nil } - let!(:timelog_list) { create_list(:timelog, 101, issue: issue) } - let(:args) { { project_id: global_id_of(project) } } - let(:extra_args) { {} } - - it 'pagination returns `default_max_page_size` and sets `has_next_page` true' do - expect(timelogs.items.count).to be(100) - expect(timelogs.has_next_page).to be(true) - end - end - context 'when no object or arguments provided' do let(:object) { nil } let(:args) { {} } @@ -286,6 +274,21 @@ RSpec.describe Resolvers::TimelogResolver do end end + context 'when the sort argument is provided' do + let_it_be(:timelog_a) { create(:issue_timelog, time_spent: 7200, spent_at: 1.hour.ago, user: current_user) } + let_it_be(:timelog_b) { create(:issue_timelog, time_spent: 5400, spent_at: 2.hours.ago, user: current_user) } + let_it_be(:timelog_c) { create(:issue_timelog, time_spent: 1800, spent_at: 30.minutes.ago, user: current_user) } + let_it_be(:timelog_d) { create(:issue_timelog, time_spent: 3600, spent_at: 1.day.ago, user: current_user) } + + let(:object) { current_user } + let(:args) { { sort: 'TIME_SPENT_ASC' } } + let(:extra_args) { {} } + + it 'returns all the timelogs in the correct order' do + expect(timelogs.items).to eq([timelog_c, timelog_d, timelog_b, timelog_a]) + end + end + def resolve_timelogs(user: current_user, obj: object, **args) context = { current_user: user } resolve(described_class, obj: obj, args: args.merge(extra_args), ctx: context) diff --git a/spec/graphql/types/access_level_enum_spec.rb b/spec/graphql/types/access_level_enum_spec.rb index 1b379c56ff9..6a8d2e26e65 100644 --- a/spec/graphql/types/access_level_enum_spec.rb +++ b/spec/graphql/types/access_level_enum_spec.rb @@ -6,6 +6,6 @@ RSpec.describe GitlabSchema.types['AccessLevelEnum'] do specify { expect(described_class.graphql_name).to eq('AccessLevelEnum') } it 'exposes all the existing access levels' do - expect(described_class.values.keys).to match_array(%w[NO_ACCESS MINIMAL_ACCESS GUEST REPORTER DEVELOPER MAINTAINER OWNER]) + expect(described_class.values.keys).to include(*%w[NO_ACCESS MINIMAL_ACCESS GUEST REPORTER DEVELOPER MAINTAINER OWNER]) end end diff --git a/spec/graphql/types/achievements/achievement_type_spec.rb b/spec/graphql/types/achievements/achievement_type_spec.rb new file mode 100644 index 00000000000..5c98753ac66 --- /dev/null +++ b/spec/graphql/types/achievements/achievement_type_spec.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['Achievement'], feature_category: :users do + include GraphqlHelpers + + let(:fields) do + %w[ + id + namespace + name + avatar_url + description + revokeable + created_at + updated_at + ] + end + + it { expect(described_class.graphql_name).to eq('Achievement') } + it { expect(described_class).to have_graphql_fields(fields) } + it { expect(described_class).to require_graphql_authorizations(:read_achievement) } + + describe '#avatar_url' do + let(:object) { instance_double(Achievements::Achievement) } + let(:current_user) { instance_double(User) } + + before do + allow(described_class).to receive(:authorized?).and_return(true) + end + + it 'calls Achievement#avatar_url(only_path: false)' do + allow(object).to receive(:avatar_url).with(only_path: false) + resolve_field(:avatar_url, object, current_user: current_user) + expect(object).to have_received(:avatar_url).with(only_path: false).once + end + end +end diff --git a/spec/graphql/types/alert_management/alert_type_spec.rb b/spec/graphql/types/alert_management/alert_type_spec.rb index c1df24ccb5c..4428fc0683a 100644 --- a/spec/graphql/types/alert_management/alert_type_spec.rb +++ b/spec/graphql/types/alert_management/alert_type_spec.rb @@ -38,6 +38,7 @@ RSpec.describe GitlabSchema.types['AlertManagementAlert'], feature_category: :in prometheus_alert environment web_url + commenters ] expect(described_class).to have_graphql_fields(*expected_fields) diff --git a/spec/graphql/types/ci/runner_countable_connection_type_spec.rb b/spec/graphql/types/ci/runner_countable_connection_type_spec.rb new file mode 100644 index 00000000000..49254ed0f93 --- /dev/null +++ b/spec/graphql/types/ci/runner_countable_connection_type_spec.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Types::Ci::RunnerCountableConnectionType, feature_category: :runner_fleet do + it 'contains attributes related to a runner connection' do + expected_fields = %w[count] + + expect(described_class).to include_graphql_fields(*expected_fields) + end +end diff --git a/spec/graphql/types/description_version_type_spec.rb b/spec/graphql/types/description_version_type_spec.rb new file mode 100644 index 00000000000..36bb1af7f7b --- /dev/null +++ b/spec/graphql/types/description_version_type_spec.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['DescriptionVersion'], feature_category: :team_planning do + it { expect(described_class).to have_graphql_field(:id) } + it { expect(described_class).to have_graphql_field(:description) } + + specify { expect(described_class).to require_graphql_authorizations(:read_issuable) } +end diff --git a/spec/graphql/types/design_management/design_type_spec.rb b/spec/graphql/types/design_management/design_type_spec.rb index 9c460e9058a..24b007a6b33 100644 --- a/spec/graphql/types/design_management/design_type_spec.rb +++ b/spec/graphql/types/design_management/design_type_spec.rb @@ -8,7 +8,7 @@ RSpec.describe GitlabSchema.types['Design'] do specify { expect(described_class.interfaces).to include(Types::TodoableInterface) } it_behaves_like 'a GraphQL type with design fields' do - let(:extra_design_fields) { %i[notes current_user_todos discussions versions web_url] } + let(:extra_design_fields) { %i[notes current_user_todos discussions versions web_url commenters] } 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)) } diff --git a/spec/graphql/types/issue_type_spec.rb b/spec/graphql/types/issue_type_spec.rb index dc444f90627..498625dc642 100644 --- a/spec/graphql/types/issue_type_spec.rb +++ b/spec/graphql/types/issue_type_spec.rb @@ -3,6 +3,9 @@ require 'spec_helper' RSpec.describe GitlabSchema.types['Issue'] do + let_it_be_with_reload(:project) { create(:project, :public) } + let_it_be(:user) { create(:user) } + specify { expect(described_class).to expose_permissions_using(Types::PermissionTypes::Issue) } specify { expect(described_class.graphql_name).to eq('Issue') } @@ -26,8 +29,6 @@ RSpec.describe GitlabSchema.types['Issue'] do 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) } @@ -130,8 +131,6 @@ RSpec.describe GitlabSchema.types['Issue'] do end describe "issue notes" do - let(:user) { create(:user) } - let(:project) { create(:project, :public) } let(:issue) { create(:issue, project: project) } let(:confidential_issue) { create(:issue, :confidential, project: project) } let(:private_note_body) { "mentioned in issue #{confidential_issue.to_reference(project)}" } @@ -211,8 +210,6 @@ RSpec.describe GitlabSchema.types['Issue'] do describe 'hidden', :enable_admin_mode do let_it_be(:admin) { create(:user, :admin) } let_it_be(:banned_user) { create(:user, :banned) } - let_it_be(:user) { create(:user) } - let_it_be(:project) { create(:project, :public) } let_it_be(:hidden_issue) { create(:issue, project: project, author: banned_user) } let_it_be(:visible_issue) { create(:issue, project: project, author: user) } @@ -259,8 +256,6 @@ RSpec.describe GitlabSchema.types['Issue'] do end describe 'escalation_status' do - let_it_be(:user) { create(:user) } - let_it_be(:project) { create(:project, :public) } let_it_be(:issue, reload: true) { create(:issue, project: project) } let(:execute) { GitlabSchema.execute(query, context: { current_user: user }).as_json } @@ -294,4 +289,44 @@ RSpec.describe GitlabSchema.types['Issue'] do end end end + + describe 'type' do + let_it_be(:issue) { create(:issue, project: project) } + + let(:query) do + %( + query { + issue(id: "#{issue.to_gid}") { + type + } + } + ) + end + + subject(:execute) { GitlabSchema.execute(query, context: { current_user: user }).as_json } + + context 'when the issue_type_uses_work_item_types_table feature flag is enabled' do + it 'gets the type field from the work_item_types table' do + expect_next_instance_of(::IssuePresenter) do |presented_issue| + expect(presented_issue).to receive_message_chain(:work_item_type, :base_type) + end + + execute + end + end + + context 'when the issue_type_uses_work_item_types_table feature flag is disabled' do + before do + stub_feature_flags(issue_type_uses_work_item_types_table: false) + end + + it 'does not get the type field from the work_item_types table' do + expect_next_instance_of(::IssuePresenter) do |presented_issue| + expect(presented_issue).not_to receive(:work_item_type) + end + + execute + end + end + end end diff --git a/spec/graphql/types/member_access_level_enum_spec.rb b/spec/graphql/types/member_access_level_enum_spec.rb new file mode 100644 index 00000000000..54aef667695 --- /dev/null +++ b/spec/graphql/types/member_access_level_enum_spec.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Types::MemberAccessLevelEnum, feature_category: :subgroups do + specify { expect(described_class.graphql_name).to eq('MemberAccessLevel') } + + it 'exposes all the existing access levels' do + expect(described_class.values.keys).to include(*%w[GUEST REPORTER DEVELOPER MAINTAINER OWNER]) + end +end diff --git a/spec/graphql/types/namespace_type_spec.rb b/spec/graphql/types/namespace_type_spec.rb index 168a6ba4eaa..d80235023ef 100644 --- a/spec/graphql/types/namespace_type_spec.rb +++ b/spec/graphql/types/namespace_type_spec.rb @@ -9,7 +9,7 @@ RSpec.describe GitlabSchema.types['Namespace'] do expected_fields = %w[ id name path full_name full_path description description_html visibility lfs_enabled request_access_enabled projects root_storage_statistics shared_runners_setting - timelog_categories + timelog_categories achievements ] expect(described_class).to include_graphql_fields(*expected_fields) diff --git a/spec/graphql/types/notes/note_type_spec.rb b/spec/graphql/types/notes/note_type_spec.rb index cbf7f086dbe..a9e45b29eea 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' -RSpec.describe GitlabSchema.types['Note'] do +RSpec.describe GitlabSchema.types['Note'], feature_category: :team_planning do it 'exposes the expected fields' do expected_fields = %i[ author @@ -24,6 +24,9 @@ RSpec.describe GitlabSchema.types['Note'] do updated_at user_permissions url + last_edited_at + last_edited_by + system_note_metadata ] expect(described_class).to have_graphql_fields(*expected_fields) diff --git a/spec/graphql/types/notes/noteable_interface_spec.rb b/spec/graphql/types/notes/noteable_interface_spec.rb index be2c30aac72..e11dece60b8 100644 --- a/spec/graphql/types/notes/noteable_interface_spec.rb +++ b/spec/graphql/types/notes/noteable_interface_spec.rb @@ -7,6 +7,7 @@ RSpec.describe Types::Notes::NoteableInterface do expected_fields = %i[ discussions notes + commenters ] expect(described_class).to have_graphql_fields(*expected_fields) diff --git a/spec/graphql/types/notes/system_note_metadata_type_spec.rb b/spec/graphql/types/notes/system_note_metadata_type_spec.rb new file mode 100644 index 00000000000..d243e926ff5 --- /dev/null +++ b/spec/graphql/types/notes/system_note_metadata_type_spec.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['SystemNoteMetadata'], feature_category: :team_planning do + it { expect(described_class).to have_graphql_field(:id) } + it { expect(described_class).to have_graphql_field(:action) } + it { expect(described_class).to have_graphql_field(:description_version) } + + specify { expect(described_class).to require_graphql_authorizations(:read_note) } +end diff --git a/spec/graphql/types/query_type_spec.rb b/spec/graphql/types/query_type_spec.rb index 514d24a209e..f06759e30c8 100644 --- a/spec/graphql/types/query_type_spec.rb +++ b/spec/graphql/types/query_type_spec.rb @@ -8,29 +8,40 @@ RSpec.describe GitlabSchema.types['Query'] do end it 'has the expected fields' do - expected_fields = %i[ - project - namespace - group - echo - metadata - current_user - snippets - design_management - milestone - user - users - issue - merge_request - usage_trends_measurements - runner_platforms - runner - runners - timelogs - board_list - topics - gitpod_enabled - ci_variables + expected_fields = [ + :board_list, + :ci_application_settings, + :ci_config, + :ci_variables, + :container_repository, + :current_user, + :design_management, + :echo, + :gitpod_enabled, + :group, + :issue, + :issues, + :jobs, + :merge_request, + :metadata, + :milestone, + :namespace, + :package, + :project, + :projects, + :query_complexity, + :runner, + :runner_platforms, + :runner_setup, + :runners, + :snippets, + :timelogs, + :todo, + :topics, + :usage_trends_measurements, + :user, + :users, + :work_item ] expect(described_class).to have_graphql_fields(*expected_fields).at_least @@ -135,7 +146,7 @@ RSpec.describe GitlabSchema.types['Query'] do subject { described_class.fields['timelogs'] } it 'returns timelogs' do - is_expected.to have_graphql_arguments(:startDate, :endDate, :startTime, :endTime, :username, :projectId, :groupId, :after, :before, :first, :last) + is_expected.to have_graphql_arguments(:startDate, :endDate, :startTime, :endTime, :username, :projectId, :groupId, :after, :before, :first, :last, :sort) is_expected.to have_graphql_type(Types::TimelogType.connection_type) is_expected.to have_graphql_resolver(Resolvers::TimelogResolver) end diff --git a/spec/graphql/types/repository/blob_type_spec.rb b/spec/graphql/types/repository/blob_type_spec.rb index 787b5f4a311..9537fca7322 100644 --- a/spec/graphql/types/repository/blob_type_spec.rb +++ b/spec/graphql/types/repository/blob_type_spec.rb @@ -2,7 +2,9 @@ require 'spec_helper' -RSpec.describe Types::Repository::BlobType do +RSpec.describe Types::Repository::BlobType, feature_category: :source_code_management do + include GraphqlHelpers + specify { expect(described_class.graphql_name).to eq('RepositoryBlob') } specify do @@ -48,4 +50,13 @@ RSpec.describe Types::Repository::BlobType do :language ).at_least end + + it 'handles blobs of huge size', :aggregate_failures do + huge_blob = Blob.new(double) + size = 10**10 + allow(huge_blob).to receive_messages({ size: size, raw_size: size }) + + expect(resolve_field(:raw_size, huge_blob)).to eq(size) + expect(resolve_field(:size, huge_blob)).to eq(size) + end end diff --git a/spec/graphql/types/snippet_type_spec.rb b/spec/graphql/types/snippet_type_spec.rb index f284d88180c..a46c51e0a27 100644 --- a/spec/graphql/types/snippet_type_spec.rb +++ b/spec/graphql/types/snippet_type_spec.rb @@ -13,7 +13,7 @@ RSpec.describe GitlabSchema.types['Snippet'] do :visibility_level, :created_at, :updated_at, :web_url, :raw_url, :ssh_url_to_repo, :http_url_to_repo, :notes, :discussions, :user_permissions, - :description_html, :blobs] + :description_html, :blobs, :commenters] expect(described_class).to have_graphql_fields(*expected_fields) end diff --git a/spec/graphql/types/time_tracking/timelog_connection_type_spec.rb b/spec/graphql/types/time_tracking/timelog_connection_type_spec.rb new file mode 100644 index 00000000000..5cfe561b42c --- /dev/null +++ b/spec/graphql/types/time_tracking/timelog_connection_type_spec.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['TimelogConnection'], feature_category: :team_planning do + it 'has the expected fields' do + expected_fields = %i[count page_info edges nodes total_spent_time] + + expect(described_class).to have_graphql_fields(*expected_fields) + end + + context 'for total_spent_time field' do + let_it_be(:current_user) { create(:user) } + let_it_be(:group) { create(:group) } + let_it_be(:project) { create(:project, :empty_repo, :public, group: group) } + let_it_be(:issue) { create(:issue, project: project) } + + let_it_be(:timelog1) { create(:issue_timelog, issue: issue, time_spent: 1000) } + let_it_be(:timelog2) { create(:issue_timelog, issue: issue, time_spent: 1500) } + let_it_be(:timelog3) { create(:issue_timelog, issue: issue, time_spent: 2564) } + + let(:query) do + %( + { + project(fullPath: "#{project.full_path}") { + timelogs { + totalSpentTime + } + } + } + ) + end + + let(:total_spent_time) { subject.dig('data', 'project', 'timelogs', 'totalSpentTime') } + + subject { GitlabSchema.execute(query, context: { current_user: current_user }).as_json } + + context 'when requested' do + it 'returns the total spent time' do + expect(total_spent_time).to eq(5064) + end + end + end +end diff --git a/spec/graphql/types/time_tracking/timelog_sort_enum_spec.rb b/spec/graphql/types/time_tracking/timelog_sort_enum_spec.rb new file mode 100644 index 00000000000..ecc11256c85 --- /dev/null +++ b/spec/graphql/types/time_tracking/timelog_sort_enum_spec.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['TimelogSort'], feature_category: :team_planning do + specify { expect(described_class.graphql_name).to eq('TimelogSort') } + + it_behaves_like 'common sort values' + + it 'exposes all the contact sort values' do + expect(described_class.values.keys).to include( + *%w[ + SPENT_AT_ASC + SPENT_AT_DESC + TIME_SPENT_ASC + TIME_SPENT_DESC + ] + ) + end +end diff --git a/spec/graphql/types/timelog_type_spec.rb b/spec/graphql/types/timelog_type_spec.rb index 3a26ba89e04..59a0e373c5d 100644 --- a/spec/graphql/types/timelog_type_spec.rb +++ b/spec/graphql/types/timelog_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe GitlabSchema.types['Timelog'] do +RSpec.describe GitlabSchema.types['Timelog'], feature_category: :team_planning do let_it_be(:fields) { %i[id spent_at time_spent user issue merge_request note summary userPermissions] } it { expect(described_class.graphql_name).to eq('Timelog') } diff --git a/spec/graphql/types/user_type_spec.rb b/spec/graphql/types/user_type_spec.rb index dcf25ff0667..45cb960cf20 100644 --- a/spec/graphql/types/user_type_spec.rb +++ b/spec/graphql/types/user_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe GitlabSchema.types['User'] do +RSpec.describe GitlabSchema.types['User'], feature_category: :users do specify { expect(described_class.graphql_name).to eq('User') } specify do @@ -20,7 +20,10 @@ RSpec.describe GitlabSchema.types['User'] do name username email + emails publicEmail + commitEmail + namespaceCommitEmails avatarUrl webUrl webPath @@ -226,4 +229,20 @@ RSpec.describe GitlabSchema.types['User'] do is_expected.to have_graphql_type(Types::TimelogType.connection_type) end end + + describe 'emails field' do + subject { described_class.fields['emails'] } + + it 'returns user emails' do + is_expected.to have_graphql_type(Types::Users::EmailType.connection_type) + end + end + + describe 'namespaceCommitEmails field' do + subject { described_class.fields['namespaceCommitEmails'] } + + it 'returns user namespace_commit_emails' do + is_expected.to have_graphql_type(Types::Users::NamespaceCommitEmailType.connection_type) + end + end end diff --git a/spec/graphql/types/users/email_type_spec.rb b/spec/graphql/types/users/email_type_spec.rb new file mode 100644 index 00000000000..fb484915428 --- /dev/null +++ b/spec/graphql/types/users/email_type_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true +require 'spec_helper' + +RSpec.describe GitlabSchema.types['Email'], feature_category: :users do + it 'has the correct fields' do + expected_fields = [ + :id, + :email, + :confirmed_at, + :created_at, + :updated_at + ] + + expect(described_class).to have_graphql_fields(*expected_fields) + end + + specify { expect(described_class).to require_graphql_authorizations(:read_user_email_address) } +end diff --git a/spec/graphql/types/users/namespace_commit_email_type_spec.rb b/spec/graphql/types/users/namespace_commit_email_type_spec.rb new file mode 100644 index 00000000000..ccab881676e --- /dev/null +++ b/spec/graphql/types/users/namespace_commit_email_type_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true +require 'spec_helper' + +RSpec.describe GitlabSchema.types['NamespaceCommitEmail'], feature_category: :users do + it 'has the correct fields' do + expected_fields = [ + :id, + :email, + :namespace, + :created_at, + :updated_at + ] + + expect(described_class).to have_graphql_fields(*expected_fields) + end + + specify { expect(described_class).to require_graphql_authorizations(:read_user_email_address) } +end |