diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-16 21:18:33 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-16 21:18:33 +0300 |
commit | f64a639bcfa1fc2bc89ca7db268f594306edfd7c (patch) | |
tree | a2c3c2ebcc3b45e596949db485d6ed18ffaacfa1 /spec/graphql/resolvers | |
parent | bfbc3e0d6583ea1a91f627528bedc3d65ba4b10f (diff) |
Add latest changes from gitlab-org/gitlab@13-10-stable-eev13.10.0-rc40
Diffstat (limited to 'spec/graphql/resolvers')
16 files changed, 203 insertions, 59 deletions
diff --git a/spec/graphql/resolvers/admin/analytics/instance_statistics/measurements_resolver_spec.rb b/spec/graphql/resolvers/admin/analytics/usage_trends/measurements_resolver_spec.rb index 578d679ade4..269a1fb1758 100644 --- a/spec/graphql/resolvers/admin/analytics/instance_statistics/measurements_resolver_spec.rb +++ b/spec/graphql/resolvers/admin/analytics/usage_trends/measurements_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Resolvers::Admin::Analytics::InstanceStatistics::MeasurementsResolver do +RSpec.describe Resolvers::Admin::Analytics::UsageTrends::MeasurementsResolver do include GraphqlHelpers let_it_be(:admin_user) { create(:user, :admin) } @@ -11,8 +11,8 @@ RSpec.describe Resolvers::Admin::Analytics::InstanceStatistics::MeasurementsReso describe '#resolve' do let_it_be(:user) { create(:user) } - let_it_be(:project_measurement_new) { create(:instance_statistics_measurement, :project_count, recorded_at: 2.days.ago) } - let_it_be(:project_measurement_old) { create(:instance_statistics_measurement, :project_count, recorded_at: 10.days.ago) } + let_it_be(:project_measurement_new) { create(:usage_trends_measurement, :project_count, recorded_at: 2.days.ago) } + let_it_be(:project_measurement_old) { create(:usage_trends_measurement, :project_count, recorded_at: 10.days.ago) } let(:arguments) { { identifier: 'projects' } } @@ -63,8 +63,8 @@ RSpec.describe Resolvers::Admin::Analytics::InstanceStatistics::MeasurementsReso end context 'when requesting pipeline counts by pipeline status' do - let_it_be(:pipelines_succeeded_measurement) { create(:instance_statistics_measurement, :pipelines_succeeded_count, recorded_at: 2.days.ago) } - let_it_be(:pipelines_skipped_measurement) { create(:instance_statistics_measurement, :pipelines_skipped_count, recorded_at: 2.days.ago) } + let_it_be(:pipelines_succeeded_measurement) { create(:usage_trends_measurement, :pipelines_succeeded_count, recorded_at: 2.days.ago) } + let_it_be(:pipelines_skipped_measurement) { create(:usage_trends_measurement, :pipelines_skipped_count, recorded_at: 2.days.ago) } subject { resolve_measurements({ identifier: identifier }, { current_user: current_user }) } diff --git a/spec/graphql/resolvers/alert_management/http_integrations_resolver_spec.rb b/spec/graphql/resolvers/alert_management/http_integrations_resolver_spec.rb new file mode 100644 index 00000000000..2cd61dd7bcf --- /dev/null +++ b/spec/graphql/resolvers/alert_management/http_integrations_resolver_spec.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Resolvers::AlertManagement::HttpIntegrationsResolver do + include GraphqlHelpers + + let_it_be(:guest) { create(:user) } + let_it_be(:developer) { create(:user) } + let_it_be(:maintainer) { create(:user) } + let_it_be(:project) { create(:project) } + let_it_be(:prometheus_integration) { create(:prometheus_service, project: project) } + let_it_be(:active_http_integration) { create(:alert_management_http_integration, project: project) } + let_it_be(:inactive_http_integration) { create(:alert_management_http_integration, :inactive, project: project) } + let_it_be(:other_proj_integration) { create(:alert_management_http_integration) } + + subject { sync(resolve_http_integrations) } + + before do + project.add_developer(developer) + project.add_maintainer(maintainer) + end + + specify do + expect(described_class).to have_nullable_graphql_type(Types::AlertManagement::HttpIntegrationType.connection_type) + end + + context 'user does not have permission' do + let(:current_user) { guest } + + it { is_expected.to be_empty } + end + + context 'user has developer permission' do + let(:current_user) { developer } + + it { is_expected.to be_empty } + end + + context 'user has maintainer permission' do + let(:current_user) { maintainer } + + it { is_expected.to contain_exactly(active_http_integration) } + end + + private + + def resolve_http_integrations(args = {}, context = { current_user: current_user }) + resolve(described_class, obj: project, ctx: context) + end +end diff --git a/spec/graphql/resolvers/board_resolver_spec.rb b/spec/graphql/resolvers/board_resolver_spec.rb index c70c696005f..e9c51a536ee 100644 --- a/spec/graphql/resolvers/board_resolver_spec.rb +++ b/spec/graphql/resolvers/board_resolver_spec.rb @@ -14,8 +14,8 @@ RSpec.describe Resolvers::BoardResolver do expect(resolve_board(id: dummy_gid)).to eq nil end - it 'calls Boards::ListService' do - expect_next_instance_of(Boards::ListService) do |service| + it 'calls Boards::BoardsFinder' do + expect_next_instance_of(Boards::BoardsFinder) do |service| expect(service).to receive(:execute).and_return([]) end diff --git a/spec/graphql/resolvers/boards_resolver_spec.rb b/spec/graphql/resolvers/boards_resolver_spec.rb index f121e8a4083..cb3bcb002ec 100644 --- a/spec/graphql/resolvers/boards_resolver_spec.rb +++ b/spec/graphql/resolvers/boards_resolver_spec.rb @@ -12,8 +12,8 @@ RSpec.describe Resolvers::BoardsResolver do expect(resolve_boards).to eq [] end - it 'calls Boards::ListService' do - expect_next_instance_of(Boards::ListService) do |service| + it 'calls Boards::BoardsFinder' do + expect_next_instance_of(Boards::BoardsFinder) do |service| expect(service).to receive(:execute) end diff --git a/spec/graphql/resolvers/branch_commit_resolver_spec.rb b/spec/graphql/resolvers/branch_commit_resolver_spec.rb index 78d4959c3f9..346c9e01088 100644 --- a/spec/graphql/resolvers/branch_commit_resolver_spec.rb +++ b/spec/graphql/resolvers/branch_commit_resolver_spec.rb @@ -12,7 +12,11 @@ RSpec.describe Resolvers::BranchCommitResolver do describe '#resolve' do it 'resolves commit' do - is_expected.to eq(repository.commits('master', limit: 1).last) + expect(sync(commit)).to eq(repository.commits('master', limit: 1).last) + end + + it 'sets project container' do + expect(sync(commit).container).to eq(repository.project) end context 'when branch does not exist' do @@ -22,5 +26,19 @@ RSpec.describe Resolvers::BranchCommitResolver do is_expected.to be_nil end end + + it 'is N+1 safe' do + commit_a = repository.commits('master', limit: 1).last + commit_b = repository.commits('spooky-stuff', limit: 1).last + + commits = batch_sync(max_queries: 1) do + [ + resolve(described_class, obj: branch), + resolve(described_class, obj: repository.find_branch('spooky-stuff')) + ] + end + + expect(commits).to contain_exactly(commit_a, commit_b) + end end end diff --git a/spec/graphql/resolvers/concerns/caching_array_resolver_spec.rb b/spec/graphql/resolvers/concerns/caching_array_resolver_spec.rb index 5370f7a7433..e9e7fff6e6e 100644 --- a/spec/graphql/resolvers/concerns/caching_array_resolver_spec.rb +++ b/spec/graphql/resolvers/concerns/caching_array_resolver_spec.rb @@ -9,7 +9,6 @@ RSpec.describe ::CachingArrayResolver do let_it_be(:admins) { create_list(:user, 4, admin: true) } let(:query_context) { { current_user: admins.first } } let(:max_page_size) { 10 } - let(:field) { double('Field', max_page_size: max_page_size) } let(:schema) do Class.new(GitlabSchema) do default_max_page_size 3 @@ -210,6 +209,6 @@ RSpec.describe ::CachingArrayResolver do args = { is_admin: admin } opts = resolver.field_options allow(resolver).to receive(:field_options).and_return(opts.merge(max_page_size: max_page_size)) - resolve(resolver, args: args, ctx: query_context, schema: schema, field: field) + resolve(resolver, args: args, ctx: query_context, schema: schema) end end diff --git a/spec/graphql/resolvers/error_tracking/sentry_errors_resolver_spec.rb b/spec/graphql/resolvers/error_tracking/sentry_errors_resolver_spec.rb index 170a602fb0d..68badb8e333 100644 --- a/spec/graphql/resolvers/error_tracking/sentry_errors_resolver_spec.rb +++ b/spec/graphql/resolvers/error_tracking/sentry_errors_resolver_spec.rb @@ -19,7 +19,7 @@ RSpec.describe Resolvers::ErrorTracking::SentryErrorsResolver do end describe '#resolve' do - context 'insufficient user permission' do + context 'with insufficient user permission' do let(:user) { create(:user) } it 'returns nil' do @@ -29,7 +29,7 @@ RSpec.describe Resolvers::ErrorTracking::SentryErrorsResolver do end end - context 'user with permission' do + context 'with sufficient permission' do before do project.add_developer(current_user) @@ -93,7 +93,7 @@ RSpec.describe Resolvers::ErrorTracking::SentryErrorsResolver do end it 'returns an externally paginated array' do - expect(resolve_errors).to be_a Gitlab::Graphql::ExternallyPaginatedArray + expect(resolve_errors).to be_a Gitlab::Graphql::Pagination::ExternallyPaginatedArrayConnection end end end diff --git a/spec/graphql/resolvers/group_labels_resolver_spec.rb b/spec/graphql/resolvers/group_labels_resolver_spec.rb index ed94f12502a..3f4ad8760c0 100644 --- a/spec/graphql/resolvers/group_labels_resolver_spec.rb +++ b/spec/graphql/resolvers/group_labels_resolver_spec.rb @@ -42,7 +42,7 @@ RSpec.describe Resolvers::GroupLabelsResolver do context 'without parent' do it 'returns no labels' do - expect(resolve_labels(nil)).to eq(Label.none) + expect(resolve_labels(nil)).to be_empty end end diff --git a/spec/graphql/resolvers/group_packages_resolver_spec.rb b/spec/graphql/resolvers/group_packages_resolver_spec.rb new file mode 100644 index 00000000000..59438b8d5ad --- /dev/null +++ b/spec/graphql/resolvers/group_packages_resolver_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Resolvers::GroupPackagesResolver do + include GraphqlHelpers + + let_it_be(:user) { create(:user) } + let_it_be(:group) { create(:group, :public) } + let_it_be(:project) { create(:project, :public, group: group) } + let_it_be(:package) { create(:package, project: project) } + + describe '#resolve' do + subject(:packages) { resolve(described_class, ctx: { current_user: user }, obj: group) } + + it { is_expected.to contain_exactly(package) } + end +end diff --git a/spec/graphql/resolvers/issues_resolver_spec.rb b/spec/graphql/resolvers/issues_resolver_spec.rb index 8980f4aa19d..6e802bf7d25 100644 --- a/spec/graphql/resolvers/issues_resolver_spec.rb +++ b/spec/graphql/resolvers/issues_resolver_spec.rb @@ -264,7 +264,7 @@ RSpec.describe Resolvers::IssuesResolver do end it 'finds a specific issue with iid', :request_store do - result = batch_sync(max_queries: 4) { resolve_issues(iid: issue1.iid) } + result = batch_sync(max_queries: 4) { resolve_issues(iid: issue1.iid).to_a } expect(result).to contain_exactly(issue1) end @@ -281,7 +281,7 @@ RSpec.describe Resolvers::IssuesResolver do it 'finds a specific issue with iids', :request_store do result = batch_sync(max_queries: 4) do - resolve_issues(iids: [issue1.iid]) + resolve_issues(iids: [issue1.iid]).to_a end expect(result).to contain_exactly(issue1) @@ -290,7 +290,7 @@ RSpec.describe Resolvers::IssuesResolver do it 'finds multiple issues with iids' do create(:issue, project: project, author: current_user) - expect(batch_sync { resolve_issues(iids: [issue1.iid, issue2.iid]) }) + expect(batch_sync { resolve_issues(iids: [issue1.iid, issue2.iid]).to_a }) .to contain_exactly(issue1, issue2) end @@ -302,7 +302,7 @@ RSpec.describe Resolvers::IssuesResolver do create(:issue, project: another_project, iid: iid) end - expect(batch_sync { resolve_issues(iids: iids) }).to contain_exactly(issue1, issue2) + expect(batch_sync { resolve_issues(iids: iids).to_a }).to contain_exactly(issue1, issue2) end end end diff --git a/spec/graphql/resolvers/labels_resolver_spec.rb b/spec/graphql/resolvers/labels_resolver_spec.rb index 3d027a6c8d5..be6229553d7 100644 --- a/spec/graphql/resolvers/labels_resolver_spec.rb +++ b/spec/graphql/resolvers/labels_resolver_spec.rb @@ -42,50 +42,36 @@ RSpec.describe Resolvers::LabelsResolver do context 'without parent' do it 'returns no labels' do - expect(resolve_labels(nil)).to eq(Label.none) + expect(resolve_labels(nil)).to be_empty end end - context 'at project level' do + context 'with a parent project' do before_all do group.add_developer(current_user) end - # because :include_ancestor_groups, :include_descendant_groups, :only_group_labels default to false - # the `nil` value would be equivalent to passing in `false` so just check for `nil` option - where(:include_ancestor_groups, :include_descendant_groups, :only_group_labels, :search_term, :test) do - nil | nil | nil | nil | -> { expect(subject).to contain_exactly(label1, label2, subgroup_label1, subgroup_label2) } - nil | nil | true | nil | -> { expect(subject).to contain_exactly(label1, label2, subgroup_label1, subgroup_label2) } - nil | true | nil | nil | -> { expect(subject).to contain_exactly(label1, label2, subgroup_label1, subgroup_label2, sub_subgroup_label1, sub_subgroup_label2) } - nil | true | true | nil | -> { expect(subject).to contain_exactly(label1, label2, subgroup_label1, subgroup_label2, sub_subgroup_label1, sub_subgroup_label2) } - true | nil | nil | nil | -> { expect(subject).to contain_exactly(label1, label2, group_label1, group_label2, subgroup_label1, subgroup_label2) } - true | nil | true | nil | -> { expect(subject).to contain_exactly(label1, label2, group_label1, group_label2, subgroup_label1, subgroup_label2) } - true | true | nil | nil | -> { expect(subject).to contain_exactly(label1, label2, group_label1, group_label2, subgroup_label1, subgroup_label2, sub_subgroup_label1, sub_subgroup_label2) } - true | true | true | nil | -> { expect(subject).to contain_exactly(label1, label2, group_label1, group_label2, subgroup_label1, subgroup_label2, sub_subgroup_label1, sub_subgroup_label2) } - - nil | nil | nil | 'new' | -> { expect(subject).to contain_exactly(label2, subgroup_label2) } - nil | nil | true | 'new' | -> { expect(subject).to contain_exactly(label2, subgroup_label2) } - nil | true | nil | 'new' | -> { expect(subject).to contain_exactly(label2, subgroup_label2, sub_subgroup_label2) } - nil | true | true | 'new' | -> { expect(subject).to contain_exactly(label2, subgroup_label2, sub_subgroup_label2) } - true | nil | nil | 'new' | -> { expect(subject).to contain_exactly(label2, group_label2, subgroup_label2) } - true | nil | true | 'new' | -> { expect(subject).to contain_exactly(label2, group_label2, subgroup_label2) } - true | true | nil | 'new' | -> { expect(subject).to contain_exactly(label2, group_label2, subgroup_label2, sub_subgroup_label2) } - true | true | true | 'new' | -> { expect(subject).to contain_exactly(label2, group_label2, subgroup_label2, sub_subgroup_label2) } + # the expected result is wrapped in a lambda to get around the phase restrictions of RSpec::Parameterized + where(:include_ancestor_groups, :search_term, :expected_labels) do + nil | nil | -> { [label1, label2, subgroup_label1, subgroup_label2] } + false | nil | -> { [label1, label2, subgroup_label1, subgroup_label2] } + true | nil | -> { [label1, label2, group_label1, group_label2, subgroup_label1, subgroup_label2] } + nil | 'new' | -> { [label2, subgroup_label2] } + false | 'new' | -> { [label2, subgroup_label2] } + true | 'new' | -> { [label2, group_label2, subgroup_label2] } end with_them do let(:params) do { include_ancestor_groups: include_ancestor_groups, - include_descendant_groups: include_descendant_groups, - only_group_labels: only_group_labels, search_term: search_term } end subject { resolve_labels(project, params) } - it { self.instance_exec(&test) } + specify { expect(subject).to match_array(instance_exec(&expected_labels)) } end end end diff --git a/spec/graphql/resolvers/merge_requests_resolver_spec.rb b/spec/graphql/resolvers/merge_requests_resolver_spec.rb index c5c368fc88f..7dd968d90a8 100644 --- a/spec/graphql/resolvers/merge_requests_resolver_spec.rb +++ b/spec/graphql/resolvers/merge_requests_resolver_spec.rb @@ -69,7 +69,7 @@ RSpec.describe Resolvers::MergeRequestsResolver do it 'batch-resolves by target project full path and IIDS', :request_store do result = batch_sync(max_queries: queries_per_project) do - resolve_mr(project, iids: [iid_1, iid_2]) + resolve_mr(project, iids: [iid_1, iid_2]).to_a end expect(result).to contain_exactly(merge_request_1, merge_request_2) diff --git a/spec/graphql/resolvers/namespace_projects_resolver_spec.rb b/spec/graphql/resolvers/namespace_projects_resolver_spec.rb index 4ad8f99219f..147a02e1d79 100644 --- a/spec/graphql/resolvers/namespace_projects_resolver_spec.rb +++ b/spec/graphql/resolvers/namespace_projects_resolver_spec.rb @@ -6,6 +6,18 @@ RSpec.describe Resolvers::NamespaceProjectsResolver do include GraphqlHelpers let(:current_user) { create(:user) } + let(:include_subgroups) { true } + let(:sort) { nil } + let(:search) { nil } + let(:ids) { nil } + let(:args) do + { + include_subgroups: include_subgroups, + sort: sort, + search: search, + ids: ids + } + end context "with a group" do let(:group) { create(:group) } @@ -27,7 +39,7 @@ RSpec.describe Resolvers::NamespaceProjectsResolver do end it 'finds all projects including the subgroups' do - expect(resolve_projects(include_subgroups: true, sort: nil, search: nil)).to contain_exactly(project1, project2, nested_project) + expect(resolve_projects(args)).to contain_exactly(project1, project2, nested_project) end context 'with an user namespace' do @@ -38,7 +50,7 @@ RSpec.describe Resolvers::NamespaceProjectsResolver do end it 'finds all projects including the subgroups' do - expect(resolve_projects(include_subgroups: true, sort: nil, search: nil)).to contain_exactly(project1, project2) + expect(resolve_projects(args)).to contain_exactly(project1, project2) end end end @@ -48,6 +60,9 @@ RSpec.describe Resolvers::NamespaceProjectsResolver do let(:project_2) { create(:project, name: 'Test Project', path: 'test-project', namespace: namespace) } let(:project_3) { create(:project, name: 'Test', path: 'test', namespace: namespace) } + let(:sort) { :similarity } + let(:search) { 'test' } + before do project_1.add_developer(current_user) project_2.add_developer(current_user) @@ -55,7 +70,7 @@ RSpec.describe Resolvers::NamespaceProjectsResolver do end it 'returns projects ordered by similarity to the search input' do - projects = resolve_projects(include_subgroups: true, sort: :similarity, search: 'test') + projects = resolve_projects(args) project_names = projects.map { |proj| proj['name'] } expect(project_names.first).to eq('Test') @@ -63,15 +78,17 @@ RSpec.describe Resolvers::NamespaceProjectsResolver do end it 'filters out result that do not match the search input' do - projects = resolve_projects(include_subgroups: true, sort: :similarity, search: 'test') + projects = resolve_projects(args) project_names = projects.map { |proj| proj['name'] } expect(project_names).not_to include('Project') end context 'when `search` parameter is not given' do + let(:search) { nil } + it 'returns projects not ordered by similarity' do - projects = resolve_projects(include_subgroups: true, sort: :similarity, search: nil) + projects = resolve_projects(args) project_names = projects.map { |proj| proj['name'] } expect(project_names.first).not_to eq('Test') @@ -79,14 +96,40 @@ RSpec.describe Resolvers::NamespaceProjectsResolver do end context 'when only search term is given' do + let(:sort) { nil } + let(:search) { 'test' } + it 'filters out result that do not match the search input, but does not sort them' do - projects = resolve_projects(include_subgroups: true, sort: :nil, search: 'test') + projects = resolve_projects(args) project_names = projects.map { |proj| proj['name'] } expect(project_names).to contain_exactly('Test', 'Test Project') end end end + + context 'ids filtering' do + subject(:projects) { resolve_projects(args) } + + let(:include_subgroups) { false } + let(:project_3) { create(:project, name: 'Project', path: 'project', namespace: namespace) } + + context 'when ids is provided' do + let(:ids) { [project_3.to_global_id.to_s] } + + it 'returns matching project' do + expect(projects).to contain_exactly(project_3) + end + end + + context 'when ids is nil' do + let(:ids) { nil } + + it 'returns all projects' do + expect(projects).to contain_exactly(project1, project2, project_3) + end + end + end end context "when passing a non existent, batch loaded namespace" do @@ -108,7 +151,7 @@ RSpec.describe Resolvers::NamespaceProjectsResolver do expect(field.to_graphql.complexity.call({}, { include_subgroups: true }, 1)).to eq 24 end - def resolve_projects(args = { include_subgroups: false, sort: nil, search: nil }, context = { current_user: current_user }) + def resolve_projects(args = { include_subgroups: false, sort: nil, search: nil, ids: nil }, context = { current_user: current_user }) resolve(described_class, obj: namespace, args: args, ctx: context) end end diff --git a/spec/graphql/resolvers/packages_resolver_spec.rb b/spec/graphql/resolvers/project_packages_resolver_spec.rb index bc0588daf7f..c8105ed2a38 100644 --- a/spec/graphql/resolvers/packages_resolver_spec.rb +++ b/spec/graphql/resolvers/project_packages_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Resolvers::PackagesResolver do +RSpec.describe Resolvers::ProjectPackagesResolver do include GraphqlHelpers let_it_be(:user) { create(:user) } diff --git a/spec/graphql/resolvers/project_pipeline_resolver_spec.rb b/spec/graphql/resolvers/project_pipeline_resolver_spec.rb index b852b349d4f..69127c4b061 100644 --- a/spec/graphql/resolvers/project_pipeline_resolver_spec.rb +++ b/spec/graphql/resolvers/project_pipeline_resolver_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Resolvers::ProjectPipelineResolver do include GraphqlHelpers let_it_be(:project) { create(:project) } - let_it_be(:pipeline) { create(:ci_pipeline, project: project, iid: '1234') } + let_it_be(:pipeline) { create(:ci_pipeline, project: project, iid: '1234', sha: 'sha') } let_it_be(:other_pipeline) { create(:ci_pipeline) } let(:current_user) { create(:user) } @@ -30,7 +30,15 @@ RSpec.describe Resolvers::ProjectPipelineResolver do expect(result).to eq(pipeline) end - it 'keeps the queries under the threshold' do + it 'resolves pipeline for the passed sha' do + result = batch_sync do + resolve_pipeline(project, { sha: 'sha' }) + end + + expect(result).to eq(pipeline) + end + + it 'keeps the queries under the threshold for iid' do create(:ci_pipeline, project: project, iid: '1235') control = ActiveRecord::QueryRecorder.new do @@ -45,6 +53,21 @@ RSpec.describe Resolvers::ProjectPipelineResolver do end.not_to exceed_query_limit(control) end + it 'keeps the queries under the threshold for sha' do + create(:ci_pipeline, project: project, sha: 'sha2') + + control = ActiveRecord::QueryRecorder.new do + batch_sync { resolve_pipeline(project, { sha: 'sha' }) } + end + + expect do + batch_sync do + resolve_pipeline(project, { sha: 'sha' }) + resolve_pipeline(project, { sha: 'sha2' }) + end + end.not_to exceed_query_limit(control) + end + it 'does not resolve a pipeline outside the project' do result = batch_sync do resolve_pipeline(other_pipeline.project, { iid: '1234' }) @@ -53,8 +76,14 @@ RSpec.describe Resolvers::ProjectPipelineResolver do expect(result).to be_nil end - it 'errors when no iid is passed' do - expect { resolve_pipeline(project, {}) }.to raise_error(ArgumentError) + it 'errors when no iid or sha is passed' do + expect { resolve_pipeline(project, {}) } + .to raise_error(Gitlab::Graphql::Errors::ArgumentError) + end + + it 'errors when both iid and sha are passed' do + expect { resolve_pipeline(project, { iid: '1234', sha: 'sha' }) } + .to raise_error(Gitlab::Graphql::Errors::ArgumentError) end context 'when the pipeline is a dangling pipeline' do diff --git a/spec/graphql/resolvers/release_milestones_resolver_spec.rb b/spec/graphql/resolvers/release_milestones_resolver_spec.rb index f05069998d0..a5a523859f9 100644 --- a/spec/graphql/resolvers/release_milestones_resolver_spec.rb +++ b/spec/graphql/resolvers/release_milestones_resolver_spec.rb @@ -14,7 +14,7 @@ RSpec.describe Resolvers::ReleaseMilestonesResolver do describe '#resolve' do it "uses offset-pagination" do - expect(resolved).to be_a(::Gitlab::Graphql::Pagination::OffsetPaginatedRelation) + expect(resolved).to be_a(::Gitlab::Graphql::Pagination::OffsetActiveRecordRelationConnection) end it "includes the release's milestones in the returned OffsetActiveRecordRelationConnection" do |