diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /spec/graphql/resolvers | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/graphql/resolvers')
53 files changed, 189 insertions, 86 deletions
diff --git a/spec/graphql/resolvers/alert_management/alert_resolver_spec.rb b/spec/graphql/resolvers/alert_management/alert_resolver_spec.rb index 6c12f765e69..0c1ba5aab2c 100644 --- a/spec/graphql/resolvers/alert_management/alert_resolver_spec.rb +++ b/spec/graphql/resolvers/alert_management/alert_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::AlertManagement::AlertResolver do +RSpec.describe Resolvers::AlertManagement::AlertResolver do include GraphqlHelpers let_it_be(:current_user) { create(:user) } diff --git a/spec/graphql/resolvers/alert_management/alert_status_counts_resolver_spec.rb b/spec/graphql/resolvers/alert_management/alert_status_counts_resolver_spec.rb index 8eb28c8c945..b72e692f2e8 100644 --- a/spec/graphql/resolvers/alert_management/alert_status_counts_resolver_spec.rb +++ b/spec/graphql/resolvers/alert_management/alert_status_counts_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::AlertManagement::AlertStatusCountsResolver do +RSpec.describe Resolvers::AlertManagement::AlertStatusCountsResolver do include GraphqlHelpers describe '#resolve' do diff --git a/spec/graphql/resolvers/base_resolver_spec.rb b/spec/graphql/resolvers/base_resolver_spec.rb index 6c384349577..40dc2370052 100644 --- a/spec/graphql/resolvers/base_resolver_spec.rb +++ b/spec/graphql/resolvers/base_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::BaseResolver do +RSpec.describe Resolvers::BaseResolver do include GraphqlHelpers let(:resolver) do diff --git a/spec/graphql/resolvers/board_lists_resolver_spec.rb b/spec/graphql/resolvers/board_lists_resolver_spec.rb index 5f6c440a8ed..f662e9a0f62 100644 --- a/spec/graphql/resolvers/board_lists_resolver_spec.rb +++ b/spec/graphql/resolvers/board_lists_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::BoardListsResolver do +RSpec.describe Resolvers::BoardListsResolver do include GraphqlHelpers let_it_be(:user) { create(:user) } diff --git a/spec/graphql/resolvers/boards_resolver_spec.rb b/spec/graphql/resolvers/boards_resolver_spec.rb index 02d6f808118..f121e8a4083 100644 --- a/spec/graphql/resolvers/boards_resolver_spec.rb +++ b/spec/graphql/resolvers/boards_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::BoardsResolver do +RSpec.describe Resolvers::BoardsResolver do include GraphqlHelpers let_it_be(:user) { create(:user) } diff --git a/spec/graphql/resolvers/branch_commit_resolver_spec.rb b/spec/graphql/resolvers/branch_commit_resolver_spec.rb index 22e1de8f375..78d4959c3f9 100644 --- a/spec/graphql/resolvers/branch_commit_resolver_spec.rb +++ b/spec/graphql/resolvers/branch_commit_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::BranchCommitResolver do +RSpec.describe Resolvers::BranchCommitResolver do include GraphqlHelpers subject(:commit) { resolve(described_class, obj: branch) } diff --git a/spec/graphql/resolvers/ci_configuration/sast_resolver_spec.rb b/spec/graphql/resolvers/ci_configuration/sast_resolver_spec.rb new file mode 100644 index 00000000000..de69ad5d450 --- /dev/null +++ b/spec/graphql/resolvers/ci_configuration/sast_resolver_spec.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Resolvers::CiConfiguration::SastResolver do + include GraphqlHelpers + + let_it_be(:user) { create(:user) } + let_it_be(:project) { create(:project) } + + describe '#resolve' do + subject(:sast_config) { resolve(described_class, ctx: { current_user: user }, obj: project) } + + it 'returns global variable informations related to SAST' do + expect(sast_config['global'].first['field']).to eql("SECURE_ANALYZERS_PREFIX") + expect(sast_config['global'].first['label']).to eql("Image prefix") + expect(sast_config['global'].first['type']).to eql("string") + + expect(sast_config['pipeline'].first['field']).to eql("stage") + expect(sast_config['pipeline'].first['label']).to eql("Stage") + expect(sast_config['pipeline'].first['type']).to eql("dropdown") + + expect(sast_config['analyzers'].first['name']).to eql("brakeman") + expect(sast_config['analyzers'].first['label']).to eql("Brakeman") + expect(sast_config['analyzers'].first['enabled']).to be true + end + end +end diff --git a/spec/graphql/resolvers/commit_pipelines_resolver_spec.rb b/spec/graphql/resolvers/commit_pipelines_resolver_spec.rb index 93da877d714..20a0cb842a4 100644 --- a/spec/graphql/resolvers/commit_pipelines_resolver_spec.rb +++ b/spec/graphql/resolvers/commit_pipelines_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::CommitPipelinesResolver do +RSpec.describe Resolvers::CommitPipelinesResolver do include GraphqlHelpers let_it_be(:project) { create(:project) } diff --git a/spec/graphql/resolvers/concerns/looks_ahead_spec.rb b/spec/graphql/resolvers/concerns/looks_ahead_spec.rb index 8b83f887846..f13823085b8 100644 --- a/spec/graphql/resolvers/concerns/looks_ahead_spec.rb +++ b/spec/graphql/resolvers/concerns/looks_ahead_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe LooksAhead do +RSpec.describe LooksAhead do include GraphqlHelpers let_it_be(:the_user) { create(:user) } diff --git a/spec/graphql/resolvers/concerns/resolves_pipelines_spec.rb b/spec/graphql/resolvers/concerns/resolves_pipelines_spec.rb index 03ff1e11d85..3dffda75e08 100644 --- a/spec/graphql/resolvers/concerns/resolves_pipelines_spec.rb +++ b/spec/graphql/resolvers/concerns/resolves_pipelines_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ResolvesPipelines do +RSpec.describe ResolvesPipelines do include GraphqlHelpers subject(:resolver) do diff --git a/spec/graphql/resolvers/concerns/resolves_project_spec.rb b/spec/graphql/resolvers/concerns/resolves_project_spec.rb index f29f54483d6..1748d8a81a3 100644 --- a/spec/graphql/resolvers/concerns/resolves_project_spec.rb +++ b/spec/graphql/resolvers/concerns/resolves_project_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ResolvesProject do +RSpec.describe ResolvesProject do include GraphqlHelpers let(:implementing_class) do diff --git a/spec/graphql/resolvers/design_management/design_at_version_resolver_spec.rb b/spec/graphql/resolvers/design_management/design_at_version_resolver_spec.rb index a5054ae3ebf..4bdef49499c 100644 --- a/spec/graphql/resolvers/design_management/design_at_version_resolver_spec.rb +++ b/spec/graphql/resolvers/design_management/design_at_version_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::DesignManagement::DesignAtVersionResolver do +RSpec.describe Resolvers::DesignManagement::DesignAtVersionResolver do include GraphqlHelpers include DesignManagementTestHelpers diff --git a/spec/graphql/resolvers/design_management/design_resolver_spec.rb b/spec/graphql/resolvers/design_management/design_resolver_spec.rb index 857acc3d371..02d7f94612c 100644 --- a/spec/graphql/resolvers/design_management/design_resolver_spec.rb +++ b/spec/graphql/resolvers/design_management/design_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::DesignManagement::DesignResolver do +RSpec.describe Resolvers::DesignManagement::DesignResolver do include GraphqlHelpers include DesignManagementTestHelpers diff --git a/spec/graphql/resolvers/design_management/designs_resolver_spec.rb b/spec/graphql/resolvers/design_management/designs_resolver_spec.rb index 28fc9e2151d..cfa37d34fd9 100644 --- a/spec/graphql/resolvers/design_management/designs_resolver_spec.rb +++ b/spec/graphql/resolvers/design_management/designs_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::DesignManagement::DesignsResolver do +RSpec.describe Resolvers::DesignManagement::DesignsResolver do include GraphqlHelpers include DesignManagementTestHelpers diff --git a/spec/graphql/resolvers/design_management/version/design_at_version_resolver_spec.rb b/spec/graphql/resolvers/design_management/version/design_at_version_resolver_spec.rb index cc9c0436885..850b9f8cc87 100644 --- a/spec/graphql/resolvers/design_management/version/design_at_version_resolver_spec.rb +++ b/spec/graphql/resolvers/design_management/version/design_at_version_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::DesignManagement::Version::DesignAtVersionResolver do +RSpec.describe Resolvers::DesignManagement::Version::DesignAtVersionResolver do include GraphqlHelpers include_context 'four designs in three versions' diff --git a/spec/graphql/resolvers/design_management/version/designs_at_version_resolver_spec.rb b/spec/graphql/resolvers/design_management/version/designs_at_version_resolver_spec.rb index 123b26862d0..c038216ce0b 100644 --- a/spec/graphql/resolvers/design_management/version/designs_at_version_resolver_spec.rb +++ b/spec/graphql/resolvers/design_management/version/designs_at_version_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::DesignManagement::Version::DesignsAtVersionResolver do +RSpec.describe Resolvers::DesignManagement::Version::DesignsAtVersionResolver do include GraphqlHelpers include_context 'four designs in three versions' diff --git a/spec/graphql/resolvers/design_management/version_in_collection_resolver_spec.rb b/spec/graphql/resolvers/design_management/version_in_collection_resolver_spec.rb index ef50598d241..8ad928e9854 100644 --- a/spec/graphql/resolvers/design_management/version_in_collection_resolver_spec.rb +++ b/spec/graphql/resolvers/design_management/version_in_collection_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::DesignManagement::VersionInCollectionResolver do +RSpec.describe Resolvers::DesignManagement::VersionInCollectionResolver do include GraphqlHelpers include DesignManagementTestHelpers diff --git a/spec/graphql/resolvers/design_management/version_resolver_spec.rb b/spec/graphql/resolvers/design_management/version_resolver_spec.rb index e7c09351204..af1e6a73d09 100644 --- a/spec/graphql/resolvers/design_management/version_resolver_spec.rb +++ b/spec/graphql/resolvers/design_management/version_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::DesignManagement::VersionResolver do +RSpec.describe Resolvers::DesignManagement::VersionResolver do include GraphqlHelpers include DesignManagementTestHelpers diff --git a/spec/graphql/resolvers/design_management/versions_resolver_spec.rb b/spec/graphql/resolvers/design_management/versions_resolver_spec.rb index d5bab025e45..5bc1c555e9a 100644 --- a/spec/graphql/resolvers/design_management/versions_resolver_spec.rb +++ b/spec/graphql/resolvers/design_management/versions_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::DesignManagement::VersionsResolver do +RSpec.describe Resolvers::DesignManagement::VersionsResolver do include GraphqlHelpers include DesignManagementTestHelpers diff --git a/spec/graphql/resolvers/echo_resolver_spec.rb b/spec/graphql/resolvers/echo_resolver_spec.rb index 466501a4227..2182ac221f6 100644 --- a/spec/graphql/resolvers/echo_resolver_spec.rb +++ b/spec/graphql/resolvers/echo_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::EchoResolver do +RSpec.describe Resolvers::EchoResolver do include GraphqlHelpers let(:current_user) { create(:user) } diff --git a/spec/graphql/resolvers/environments_resolver_spec.rb b/spec/graphql/resolvers/environments_resolver_spec.rb index 75fd7aff39c..6c999e5d0e7 100644 --- a/spec/graphql/resolvers/environments_resolver_spec.rb +++ b/spec/graphql/resolvers/environments_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::EnvironmentsResolver do +RSpec.describe Resolvers::EnvironmentsResolver do include GraphqlHelpers let_it_be(:current_user) { create(:user) } diff --git a/spec/graphql/resolvers/error_tracking/sentry_detailed_error_resolver_spec.rb b/spec/graphql/resolvers/error_tracking/sentry_detailed_error_resolver_spec.rb index 8b2e33cdfda..7e531910184 100644 --- a/spec/graphql/resolvers/error_tracking/sentry_detailed_error_resolver_spec.rb +++ b/spec/graphql/resolvers/error_tracking/sentry_detailed_error_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::ErrorTracking::SentryDetailedErrorResolver do +RSpec.describe Resolvers::ErrorTracking::SentryDetailedErrorResolver do include GraphqlHelpers let_it_be(:project) { create(:project) } diff --git a/spec/graphql/resolvers/error_tracking/sentry_error_collection_resolver_spec.rb b/spec/graphql/resolvers/error_tracking/sentry_error_collection_resolver_spec.rb index 3bb8a5c389d..02e0420be2a 100644 --- a/spec/graphql/resolvers/error_tracking/sentry_error_collection_resolver_spec.rb +++ b/spec/graphql/resolvers/error_tracking/sentry_error_collection_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::ErrorTracking::SentryErrorCollectionResolver do +RSpec.describe Resolvers::ErrorTracking::SentryErrorCollectionResolver do include GraphqlHelpers let_it_be(:project) { create(:project) } 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 93f89d077d7..554873a6e21 100644 --- a/spec/graphql/resolvers/error_tracking/sentry_errors_resolver_spec.rb +++ b/spec/graphql/resolvers/error_tracking/sentry_errors_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::ErrorTracking::SentryErrorsResolver do +RSpec.describe Resolvers::ErrorTracking::SentryErrorsResolver do include GraphqlHelpers let_it_be(:project) { create(:project) } diff --git a/spec/graphql/resolvers/group_resolver_spec.rb b/spec/graphql/resolvers/group_resolver_spec.rb index 70b1102d363..a03e7854177 100644 --- a/spec/graphql/resolvers/group_resolver_spec.rb +++ b/spec/graphql/resolvers/group_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::GroupResolver do +RSpec.describe Resolvers::GroupResolver do include GraphqlHelpers let_it_be(:group1) { create(:group) } diff --git a/spec/graphql/resolvers/issues_resolver_spec.rb b/spec/graphql/resolvers/issues_resolver_spec.rb index b7cc9bc6d71..eb17e94a450 100644 --- a/spec/graphql/resolvers/issues_resolver_spec.rb +++ b/spec/graphql/resolvers/issues_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::IssuesResolver do +RSpec.describe Resolvers::IssuesResolver do include GraphqlHelpers let(:current_user) { create(:user) } @@ -101,12 +101,10 @@ describe Resolvers::IssuesResolver do end it 'uses project search optimization' do - expected_arguments = { + expected_arguments = a_hash_including( search: 'foo', - attempt_project_search_optimizations: true, - iids: [], - project_id: project.id - } + attempt_project_search_optimizations: true + ) expect(IssuesFinder).to receive(:new).with(anything, expected_arguments).and_call_original resolve_issues(search: 'foo') @@ -217,16 +215,32 @@ describe Resolvers::IssuesResolver do expect(resolve_issues).to contain_exactly(issue1, issue2) end - it 'finds a specific issue with iid' do - expect(resolve_issues(iid: issue1.iid)).to contain_exactly(issue1) + it 'finds a specific issue with iid', :request_store do + result = batch_sync(max_queries: 2) { resolve_issues(iid: issue1.iid) } + + expect(result).to contain_exactly(issue1) + end + + it 'batches queries that only include IIDs', :request_store do + result = batch_sync(max_queries: 2) do + resolve_issues(iid: issue1.iid) + resolve_issues(iids: issue2.iid) + end + + expect(result).to contain_exactly(issue1, issue2) end - it 'finds a specific issue with iids' do - expect(resolve_issues(iids: issue1.iid)).to contain_exactly(issue1) + it 'finds a specific issue with iids', :request_store do + result = batch_sync(max_queries: 2) do + resolve_issues(iids: [issue1.iid]) + end + + expect(result).to contain_exactly(issue1) end it 'finds multiple issues with iids' do - expect(resolve_issues(iids: [issue1.iid, issue2.iid])) + create(:issue, project: project, author: current_user) + + expect(batch_sync { resolve_issues(iids: [issue1.iid, issue2.iid]) }) .to contain_exactly(issue1, issue2) end @@ -238,7 +252,7 @@ describe Resolvers::IssuesResolver do create(:issue, project: another_project, iid: iid) end - expect(resolve_issues(iids: iids)).to contain_exactly(issue1, issue2) + expect(batch_sync { resolve_issues(iids: iids) }).to contain_exactly(issue1, issue2) end end end diff --git a/spec/graphql/resolvers/last_commit_resolver_spec.rb b/spec/graphql/resolvers/last_commit_resolver_spec.rb index 15b09b77a10..5ac6ad59864 100644 --- a/spec/graphql/resolvers/last_commit_resolver_spec.rb +++ b/spec/graphql/resolvers/last_commit_resolver_spec.rb @@ -2,10 +2,12 @@ require 'spec_helper' -describe Resolvers::LastCommitResolver do +RSpec.describe Resolvers::LastCommitResolver do include GraphqlHelpers + include RepoHelpers - let(:repository) { create(:project, :repository).repository } + let(:project) { create(:project, :repository) } + let(:repository) { project.repository } let(:tree) { repository.tree(ref, path) } let(:commit) { resolve(described_class, obj: tree) } @@ -29,6 +31,28 @@ describe Resolvers::LastCommitResolver do end end + context 'last commit for a wildcard pathspec' do + let(:ref) { 'fix' } + let(:path) { 'files/*' } + + it 'returns nil' do + expect(commit).to be_nil + end + end + + context 'last commit with pathspec characters' do + let(:ref) { 'fix' } + let(:path) { ':wq' } + + before do + create_file_in_repo(project, ref, ref, path, 'Test file') + end + + it 'resolves commit' do + expect(commit).to eq(repository.commits(ref, path: path, limit: 1).last) + end + end + context 'last commit does not exist' do let(:ref) { 'master' } let(:path) { 'does-not-exist' } diff --git a/spec/graphql/resolvers/merge_request_pipelines_resolver_spec.rb b/spec/graphql/resolvers/merge_request_pipelines_resolver_spec.rb index b894dce3e17..2fe3e86ec14 100644 --- a/spec/graphql/resolvers/merge_request_pipelines_resolver_spec.rb +++ b/spec/graphql/resolvers/merge_request_pipelines_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::MergeRequestPipelinesResolver do +RSpec.describe Resolvers::MergeRequestPipelinesResolver do include GraphqlHelpers let_it_be(:merge_request) { create(:merge_request) } diff --git a/spec/graphql/resolvers/merge_requests_resolver_spec.rb b/spec/graphql/resolvers/merge_requests_resolver_spec.rb index 6ff7e1ecac6..0a8fd82613a 100644 --- a/spec/graphql/resolvers/merge_requests_resolver_spec.rb +++ b/spec/graphql/resolvers/merge_requests_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::MergeRequestsResolver do +RSpec.describe Resolvers::MergeRequestsResolver do include GraphqlHelpers let_it_be(:project) { create(:project, :repository) } @@ -22,9 +22,12 @@ describe Resolvers::MergeRequestsResolver do before do project.add_developer(current_user) + other_project.add_developer(current_user) end describe '#resolve' do + let(:queries_per_project) { 3 } + context 'no arguments' do it 'returns all merge requests' do result = resolve_mr(project, {}) @@ -40,24 +43,34 @@ describe Resolvers::MergeRequestsResolver do end context 'by iid alone' do - it 'batch-resolves by target project full path and individual IID' do - result = batch_sync(max_queries: 2) do + it 'batch-resolves by target project full path and individual IID', :request_store do + # 1 query for project_authorizations, and 1 for merge_requests + result = batch_sync(max_queries: queries_per_project) do [iid_1, iid_2].map { |iid| resolve_mr_single(project, iid) } end expect(result).to contain_exactly(merge_request_1, merge_request_2) end - it 'batch-resolves by target project full path and IIDS' do - result = batch_sync(max_queries: 2) 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]) end expect(result).to contain_exactly(merge_request_1, merge_request_2) end + it 'batch-resolves by target project full path and IIDS, single or plural', :request_store do + result = batch_sync(max_queries: queries_per_project) do + [resolve_mr_single(project, merge_request_3.iid), *resolve_mr(project, iids: [iid_1, iid_2])] + end + + expect(result).to contain_exactly(merge_request_1, merge_request_2, merge_request_3) + end + it 'can batch-resolve merge requests from different projects' do - result = batch_sync(max_queries: 3) do + # 2 queries for project_authorizations, and 2 for merge_requests + result = batch_sync(max_queries: queries_per_project * 2) do resolve_mr(project, iids: iid_1) + resolve_mr(project, iids: iid_2) + resolve_mr(other_project, iids: other_iid) diff --git a/spec/graphql/resolvers/metadata_resolver_spec.rb b/spec/graphql/resolvers/metadata_resolver_spec.rb index afff9eabb97..20556941de4 100644 --- a/spec/graphql/resolvers/metadata_resolver_spec.rb +++ b/spec/graphql/resolvers/metadata_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::MetadataResolver do +RSpec.describe Resolvers::MetadataResolver do include GraphqlHelpers describe '#resolve' do diff --git a/spec/graphql/resolvers/metrics/dashboard_resolver_spec.rb b/spec/graphql/resolvers/metrics/dashboard_resolver_spec.rb index 6a8eb8a65af..4112e3d4fe6 100644 --- a/spec/graphql/resolvers/metrics/dashboard_resolver_spec.rb +++ b/spec/graphql/resolvers/metrics/dashboard_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::Metrics::DashboardResolver do +RSpec.describe Resolvers::Metrics::DashboardResolver do include GraphqlHelpers let_it_be(:current_user) { create(:user) } diff --git a/spec/graphql/resolvers/metrics/dashboards/annotation_resolver_spec.rb b/spec/graphql/resolvers/metrics/dashboards/annotation_resolver_spec.rb index c06fbef53b6..f90869c52bc 100644 --- a/spec/graphql/resolvers/metrics/dashboards/annotation_resolver_spec.rb +++ b/spec/graphql/resolvers/metrics/dashboards/annotation_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::Metrics::Dashboards::AnnotationResolver do +RSpec.describe Resolvers::Metrics::Dashboards::AnnotationResolver do include GraphqlHelpers describe '#resolve' do diff --git a/spec/graphql/resolvers/milestone_resolver_spec.rb b/spec/graphql/resolvers/milestone_resolver_spec.rb index 8e2c67fdc03..36dd5ef03e2 100644 --- a/spec/graphql/resolvers/milestone_resolver_spec.rb +++ b/spec/graphql/resolvers/milestone_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::MilestoneResolver do +RSpec.describe Resolvers::MilestoneResolver do include GraphqlHelpers describe '#resolve' do diff --git a/spec/graphql/resolvers/namespace_projects_resolver_spec.rb b/spec/graphql/resolvers/namespace_projects_resolver_spec.rb index 639cc69650b..699269b47e0 100644 --- a/spec/graphql/resolvers/namespace_projects_resolver_spec.rb +++ b/spec/graphql/resolvers/namespace_projects_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::NamespaceProjectsResolver do +RSpec.describe Resolvers::NamespaceProjectsResolver do include GraphqlHelpers let(:current_user) { create(:user) } diff --git a/spec/graphql/resolvers/packages_resolver_spec.rb b/spec/graphql/resolvers/packages_resolver_spec.rb new file mode 100644 index 00000000000..9aec2c7e036 --- /dev/null +++ b/spec/graphql/resolvers/packages_resolver_spec.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Resolvers::PackagesResolver do + include GraphqlHelpers + + let_it_be(:user) { create(:user) } + let_it_be(:project) { create(:project) } + let_it_be(:package) { create(:package, project: project) } + + describe '#resolve' do + subject(:packages) { resolve(described_class, ctx: { current_user: user }, obj: project) } + + it { is_expected.to contain_exactly(package) } + end +end diff --git a/spec/graphql/resolvers/project_members_resolver_spec.rb b/spec/graphql/resolvers/project_members_resolver_spec.rb index 3209838850b..602225cf632 100644 --- a/spec/graphql/resolvers/project_members_resolver_spec.rb +++ b/spec/graphql/resolvers/project_members_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::ProjectMembersResolver do +RSpec.describe Resolvers::ProjectMembersResolver do include GraphqlHelpers context "with a group" do diff --git a/spec/graphql/resolvers/project_pipeline_resolver_spec.rb b/spec/graphql/resolvers/project_pipeline_resolver_spec.rb index 72049f16d7d..a659b3bdb6e 100644 --- a/spec/graphql/resolvers/project_pipeline_resolver_spec.rb +++ b/spec/graphql/resolvers/project_pipeline_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::ProjectPipelineResolver do +RSpec.describe Resolvers::ProjectPipelineResolver do include GraphqlHelpers let_it_be(:project) { create(:project) } diff --git a/spec/graphql/resolvers/project_pipelines_resolver_spec.rb b/spec/graphql/resolvers/project_pipelines_resolver_spec.rb index 2a14796fdfa..b2e8fed2441 100644 --- a/spec/graphql/resolvers/project_pipelines_resolver_spec.rb +++ b/spec/graphql/resolvers/project_pipelines_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::ProjectPipelinesResolver do +RSpec.describe Resolvers::ProjectPipelinesResolver do include GraphqlHelpers let_it_be(:project) { create(:project) } diff --git a/spec/graphql/resolvers/project_resolver_spec.rb b/spec/graphql/resolvers/project_resolver_spec.rb index e9e38353156..72a01b1c574 100644 --- a/spec/graphql/resolvers/project_resolver_spec.rb +++ b/spec/graphql/resolvers/project_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::ProjectResolver do +RSpec.describe Resolvers::ProjectResolver do include GraphqlHelpers let_it_be(:project1) { create(:project) } diff --git a/spec/graphql/resolvers/projects/grafana_integration_resolver_spec.rb b/spec/graphql/resolvers/projects/grafana_integration_resolver_spec.rb index 416a90a841f..854e763fbdd 100644 --- a/spec/graphql/resolvers/projects/grafana_integration_resolver_spec.rb +++ b/spec/graphql/resolvers/projects/grafana_integration_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::Projects::GrafanaIntegrationResolver do +RSpec.describe Resolvers::Projects::GrafanaIntegrationResolver do include GraphqlHelpers let_it_be(:project) { create(:project) } diff --git a/spec/graphql/resolvers/projects/jira_imports_resolver_spec.rb b/spec/graphql/resolvers/projects/jira_imports_resolver_spec.rb index 9811075a613..0775c1c31d1 100644 --- a/spec/graphql/resolvers/projects/jira_imports_resolver_spec.rb +++ b/spec/graphql/resolvers/projects/jira_imports_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::Projects::JiraImportsResolver do +RSpec.describe Resolvers::Projects::JiraImportsResolver do include GraphqlHelpers describe '#resolve' do diff --git a/spec/graphql/resolvers/projects/jira_projects_resolver_spec.rb b/spec/graphql/resolvers/projects/jira_projects_resolver_spec.rb index 364e2aa6ca8..4038bcb3e5d 100644 --- a/spec/graphql/resolvers/projects/jira_projects_resolver_spec.rb +++ b/spec/graphql/resolvers/projects/jira_projects_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::Projects::JiraProjectsResolver do +RSpec.describe Resolvers::Projects::JiraProjectsResolver do include GraphqlHelpers describe '#resolve' do @@ -63,7 +63,7 @@ describe Resolvers::Projects::JiraProjectsResolver do context 'when Jira connection is not valid' do before do - WebMock.stub_request(:get, 'https://jira.example.com/rest/api/2/project/search?maxResults=50&query=&startAt=0') + WebMock.stub_request(:get, 'https://jira.example.com/rest/api/2/project') .to_raise(JIRA::HTTPError.new(double(message: 'Some failure.'))) end diff --git a/spec/graphql/resolvers/projects/services_resolver_spec.rb b/spec/graphql/resolvers/projects/services_resolver_spec.rb index 00045442ea0..8b6eff9e8b6 100644 --- a/spec/graphql/resolvers/projects/services_resolver_spec.rb +++ b/spec/graphql/resolvers/projects/services_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::Projects::ServicesResolver do +RSpec.describe Resolvers::Projects::ServicesResolver do include GraphqlHelpers describe '#resolve' do diff --git a/spec/graphql/resolvers/projects/snippets_resolver_spec.rb b/spec/graphql/resolvers/projects/snippets_resolver_spec.rb index 6d301b1c742..b4a5eb8ddb0 100644 --- a/spec/graphql/resolvers/projects/snippets_resolver_spec.rb +++ b/spec/graphql/resolvers/projects/snippets_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::Projects::SnippetsResolver do +RSpec.describe Resolvers::Projects::SnippetsResolver do include GraphqlHelpers describe '#resolve' do diff --git a/spec/graphql/resolvers/projects_resolver_spec.rb b/spec/graphql/resolvers/projects_resolver_spec.rb index 73ff99a2520..db7c9225c84 100644 --- a/spec/graphql/resolvers/projects_resolver_spec.rb +++ b/spec/graphql/resolvers/projects_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::ProjectsResolver do +RSpec.describe Resolvers::ProjectsResolver do include GraphqlHelpers describe '#resolve' do diff --git a/spec/graphql/resolvers/release_resolver_spec.rb b/spec/graphql/resolvers/release_resolver_spec.rb index 71aa4bbb439..666d54fbc3c 100644 --- a/spec/graphql/resolvers/release_resolver_spec.rb +++ b/spec/graphql/resolvers/release_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::ReleaseResolver do +RSpec.describe Resolvers::ReleaseResolver do include GraphqlHelpers let_it_be(:project) { create(:project, :private) } diff --git a/spec/graphql/resolvers/releases_resolver_spec.rb b/spec/graphql/resolvers/releases_resolver_spec.rb index 9de539b417a..ee8b33fc748 100644 --- a/spec/graphql/resolvers/releases_resolver_spec.rb +++ b/spec/graphql/resolvers/releases_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::ReleasesResolver do +RSpec.describe Resolvers::ReleasesResolver do include GraphqlHelpers let_it_be(:project) { create(:project, :private) } diff --git a/spec/graphql/resolvers/snippets_resolver_spec.rb b/spec/graphql/resolvers/snippets_resolver_spec.rb index 89c350020f0..180be8e8624 100644 --- a/spec/graphql/resolvers/snippets_resolver_spec.rb +++ b/spec/graphql/resolvers/snippets_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::SnippetsResolver do +RSpec.describe Resolvers::SnippetsResolver do include GraphqlHelpers describe '#resolve' do diff --git a/spec/graphql/resolvers/todo_resolver_spec.rb b/spec/graphql/resolvers/todo_resolver_spec.rb index 5a09ec40e64..0775cb8dae7 100644 --- a/spec/graphql/resolvers/todo_resolver_spec.rb +++ b/spec/graphql/resolvers/todo_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::TodoResolver do +RSpec.describe Resolvers::TodoResolver do include GraphqlHelpers describe '#resolve' do @@ -10,9 +10,9 @@ describe Resolvers::TodoResolver do let_it_be(:author1) { create(:user) } let_it_be(:author2) { create(:user) } - let_it_be(:todo1) { create(:todo, user: current_user, target_type: 'MergeRequest', state: :pending, action: Todo::MENTIONED, author: author1) } - let_it_be(:todo2) { create(:todo, user: current_user, state: :done, action: Todo::ASSIGNED, author: author2) } - let_it_be(:todo3) { create(:todo, user: current_user, state: :pending, action: Todo::ASSIGNED, author: author1) } + let_it_be(:merge_request_todo_pending) { create(:todo, user: current_user, target_type: 'MergeRequest', state: :pending, action: Todo::MENTIONED, author: author1) } + let_it_be(:issue_todo_done) { create(:todo, user: current_user, state: :done, action: Todo::ASSIGNED, author: author2) } + let_it_be(:issue_todo_pending) { create(:todo, user: current_user, state: :pending, action: Todo::ASSIGNED, author: author1) } it 'calls TodosFinder' do expect_next_instance_of(TodosFinder) do |finder| @@ -23,22 +23,30 @@ describe Resolvers::TodoResolver do end context 'when using no filter' do - it 'returns expected todos' do - expect(resolve_todos).to contain_exactly(todo1, todo3) + it 'returns pending todos' do + expect(resolve_todos).to contain_exactly(merge_request_todo_pending, issue_todo_pending) end end context 'when using filters' do it 'returns the todos for multiple states' do - todos = resolve_todos({ state: [:done, :pending] }) + todos = resolve_todos(state: [:done, :pending]) - expect(todos).to contain_exactly(todo1, todo2, todo3) + expect(todos).to contain_exactly(merge_request_todo_pending, issue_todo_done, issue_todo_pending) end - it 'returns the todos for multiple types' do - todos = resolve_todos({ type: %w[Issue MergeRequest] }) + it 'returns the todos for multiple filters' do + design_todo_pending = create(:todo, target_type: 'DesignManagement::Design', user: current_user, state: :pending, action: Todo::ASSIGNED, author: author1) - expect(todos).to contain_exactly(todo1, todo3) + todos = resolve_todos(type: ['MergeRequest', 'DesignManagement::Design']) + + expect(todos).to contain_exactly(merge_request_todo_pending, design_todo_pending) + end + + it 'returns the todos for single filter' do + todos = resolve_todos(type: 'MergeRequest') + + expect(todos).to contain_exactly(merge_request_todo_pending) end it 'returns the todos for multiple groups' do @@ -53,7 +61,7 @@ describe Resolvers::TodoResolver do todo5 = create(:todo, group: group2, user: current_user, state: :pending, action: Todo::ASSIGNED, author: author1) create(:todo, group: group3, user: current_user, state: :pending, action: Todo::ASSIGNED, author: author1) - todos = resolve_todos({ group_id: [group2.id, group1.id] }) + todos = resolve_todos(group_id: [group2.id, group1.id]) expect(todos).to contain_exactly(todo4, todo5) end @@ -61,20 +69,19 @@ describe Resolvers::TodoResolver do it 'returns the todos for multiple authors' do author3 = create(:user) - todo4 = create(:todo, user: current_user, state: :pending, action: Todo::ASSIGNED, author: author2) create(:todo, user: current_user, state: :pending, action: Todo::ASSIGNED, author: author3) - todos = resolve_todos({ author_id: [author2.id, author1.id] }) + todos = resolve_todos(author_id: [author2.id, author1.id]) - expect(todos).to contain_exactly(todo1, todo3, todo4) + expect(todos).to contain_exactly(merge_request_todo_pending, issue_todo_pending) end it 'returns the todos for multiple actions' do create(:todo, user: current_user, state: :pending, action: Todo::DIRECTLY_ADDRESSED, author: author1) - todos = resolve_todos({ action: [Todo::MENTIONED, Todo::ASSIGNED] }) + todos = resolve_todos(action: [Todo::MENTIONED, Todo::ASSIGNED]) - expect(todos).to contain_exactly(todo1, todo3) + expect(todos).to contain_exactly(merge_request_todo_pending, issue_todo_pending) end it 'returns the todos for multiple projects' do @@ -86,7 +93,7 @@ describe Resolvers::TodoResolver do todo5 = create(:todo, project: project2, user: current_user, state: :pending, action: Todo::ASSIGNED, author: author1) create(:todo, project: project3, user: current_user, state: :pending, action: Todo::ASSIGNED, author: author1) - todos = resolve_todos({ project_id: [project2.id, project1.id] }) + todos = resolve_todos(project_id: [project2.id, project1.id]) expect(todos).to contain_exactly(todo4, todo5) end diff --git a/spec/graphql/resolvers/tree_resolver_spec.rb b/spec/graphql/resolvers/tree_resolver_spec.rb index 0ea4e6eeaad..7818c25fe47 100644 --- a/spec/graphql/resolvers/tree_resolver_spec.rb +++ b/spec/graphql/resolvers/tree_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::TreeResolver do +RSpec.describe Resolvers::TreeResolver do include GraphqlHelpers let(:repository) { create(:project, :repository).repository } diff --git a/spec/graphql/resolvers/user_resolver_spec.rb b/spec/graphql/resolvers/user_resolver_spec.rb index 45a8816bf26..3ee9f63d832 100644 --- a/spec/graphql/resolvers/user_resolver_spec.rb +++ b/spec/graphql/resolvers/user_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::UserResolver do +RSpec.describe Resolvers::UserResolver do include GraphqlHelpers describe '#resolve' do diff --git a/spec/graphql/resolvers/users/snippets_resolver_spec.rb b/spec/graphql/resolvers/users/snippets_resolver_spec.rb index 6412d77e02b..497b6b11b46 100644 --- a/spec/graphql/resolvers/users/snippets_resolver_spec.rb +++ b/spec/graphql/resolvers/users/snippets_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::Users::SnippetsResolver do +RSpec.describe Resolvers::Users::SnippetsResolver do include GraphqlHelpers describe '#resolve' do diff --git a/spec/graphql/resolvers/users_resolver_spec.rb b/spec/graphql/resolvers/users_resolver_spec.rb index e752500d52f..e3d595e0790 100644 --- a/spec/graphql/resolvers/users_resolver_spec.rb +++ b/spec/graphql/resolvers/users_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Resolvers::UsersResolver do +RSpec.describe Resolvers::UsersResolver do include GraphqlHelpers let_it_be(:user1) { create(:user) } |