2019-12-21 20:55:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe GitlabSchema.types['Project'] do
|
2021-02-22 17:27:13 +05:30
|
|
|
include GraphqlHelpers
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
specify { expect(described_class).to expose_permissions_using(Types::PermissionTypes::Project) }
|
2018-11-08 19:23:39 +05:30
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
specify { expect(described_class.graphql_name).to eq('Project') }
|
2018-11-08 19:23:39 +05:30
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
specify { expect(described_class).to require_graphql_authorizations(:read_project) }
|
2019-07-07 11:18:12 +05:30
|
|
|
|
2019-09-30 21:07:59 +05:30
|
|
|
it 'has the expected fields' do
|
|
|
|
expected_fields = %w[
|
|
|
|
user_permissions id full_path path name_with_namespace
|
|
|
|
name description description_html tag_list ssh_url_to_repo
|
|
|
|
http_url_to_repo web_url star_count forks_count
|
|
|
|
created_at last_activity_at archived visibility
|
|
|
|
container_registry_enabled shared_runners_enabled
|
|
|
|
lfs_enabled merge_requests_ff_only_enabled avatar_url
|
|
|
|
issues_enabled merge_requests_enabled wiki_enabled
|
|
|
|
snippets_enabled jobs_enabled public_jobs open_issues_count import_status
|
|
|
|
only_allow_merge_if_pipeline_succeeds request_access_enabled
|
|
|
|
only_allow_merge_if_all_discussions_are_resolved printing_merge_request_link_enabled
|
|
|
|
namespace group statistics repository merge_requests merge_request issues
|
2020-10-24 23:57:45 +05:30
|
|
|
issue milestones pipelines removeSourceBranchAfterMerge sentryDetailedError snippets
|
2020-03-13 15:44:24 +05:30
|
|
|
grafanaIntegration autocloseReferencedIssues suggestion_commit_message environments
|
2020-10-24 23:57:45 +05:30
|
|
|
environment boards jira_import_status jira_imports services releases release
|
2020-05-24 23:13:21 +05:30
|
|
|
alert_management_alerts alert_management_alert alert_management_alert_status_counts
|
2020-10-24 23:57:45 +05:30
|
|
|
container_expiration_policy service_desk_enabled service_desk_address
|
2021-01-29 00:20:46 +05:30
|
|
|
issue_status_counts terraform_states alert_management_integrations
|
2021-02-22 17:27:13 +05:30
|
|
|
container_repositories container_repositories_count
|
|
|
|
pipeline_analytics total_pipeline_duration squash_read_only
|
2019-09-30 21:07:59 +05:30
|
|
|
]
|
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
expect(described_class).to include_graphql_fields(*expected_fields)
|
2018-11-08 19:23:39 +05:30
|
|
|
end
|
2019-12-21 20:55:43 +05:30
|
|
|
|
|
|
|
describe 'issue field' do
|
|
|
|
subject { described_class.fields['issue'] }
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
it { is_expected.to have_graphql_type(Types::IssueType) }
|
|
|
|
it { is_expected.to have_graphql_resolver(Resolvers::IssuesResolver.single) }
|
2019-12-21 20:55:43 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
describe 'issues field' do
|
|
|
|
subject { described_class.fields['issues'] }
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
it { is_expected.to have_graphql_type(Types::IssueType.connection_type) }
|
|
|
|
it { is_expected.to have_graphql_resolver(Resolvers::IssuesResolver) }
|
2019-12-21 20:55:43 +05:30
|
|
|
end
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
describe 'merge_request field' do
|
2019-12-21 20:55:43 +05:30
|
|
|
subject { described_class.fields['mergeRequest'] }
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
it { is_expected.to have_graphql_type(Types::MergeRequestType) }
|
|
|
|
it { is_expected.to have_graphql_resolver(Resolvers::MergeRequestsResolver.single) }
|
2020-06-23 00:09:42 +05:30
|
|
|
it { is_expected.to have_graphql_arguments(:iid) }
|
2019-12-21 20:55:43 +05:30
|
|
|
end
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
describe 'merge_requests field' do
|
2019-12-21 20:55:43 +05:30
|
|
|
subject { described_class.fields['mergeRequests'] }
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
it { is_expected.to have_graphql_type(Types::MergeRequestType.connection_type) }
|
2020-11-24 15:15:51 +05:30
|
|
|
it { is_expected.to have_graphql_resolver(Resolvers::ProjectMergeRequestsResolver) }
|
2020-06-23 00:09:42 +05:30
|
|
|
|
|
|
|
it do
|
|
|
|
is_expected.to have_graphql_arguments(:iids,
|
|
|
|
:source_branches,
|
|
|
|
:target_branches,
|
|
|
|
:state,
|
|
|
|
:labels,
|
|
|
|
:before,
|
|
|
|
:after,
|
|
|
|
:first,
|
2020-10-24 23:57:45 +05:30
|
|
|
:last,
|
|
|
|
:merged_after,
|
2020-11-24 15:15:51 +05:30
|
|
|
:merged_before,
|
|
|
|
:author_username,
|
|
|
|
:assignee_username,
|
2021-02-22 17:27:13 +05:30
|
|
|
:reviewer_username,
|
2020-11-24 15:15:51 +05:30
|
|
|
:milestone_title,
|
|
|
|
:sort
|
2020-06-23 00:09:42 +05:30
|
|
|
)
|
|
|
|
end
|
2019-12-21 20:55:43 +05:30
|
|
|
end
|
2020-01-01 13:55:28 +05:30
|
|
|
|
|
|
|
describe 'snippets field' do
|
|
|
|
subject { described_class.fields['snippets'] }
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
it { is_expected.to have_graphql_type(Types::SnippetType.connection_type) }
|
|
|
|
it { is_expected.to have_graphql_resolver(Resolvers::Projects::SnippetsResolver) }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'grafana_integration field' do
|
|
|
|
subject { described_class.fields['grafanaIntegration'] }
|
|
|
|
|
|
|
|
it { is_expected.to have_graphql_type(Types::GrafanaIntegrationType) }
|
|
|
|
it { is_expected.to have_graphql_resolver(Resolvers::Projects::GrafanaIntegrationResolver) }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'environments field' do
|
|
|
|
subject { described_class.fields['environments'] }
|
|
|
|
|
|
|
|
it { is_expected.to have_graphql_type(Types::EnvironmentType.connection_type) }
|
|
|
|
it { is_expected.to have_graphql_resolver(Resolvers::EnvironmentsResolver) }
|
2020-01-01 13:55:28 +05:30
|
|
|
end
|
2020-04-08 14:13:33 +05:30
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
describe 'environment field' do
|
|
|
|
subject { described_class.fields['environment'] }
|
|
|
|
|
|
|
|
it { is_expected.to have_graphql_type(Types::EnvironmentType) }
|
|
|
|
it { is_expected.to have_graphql_resolver(Resolvers::EnvironmentsResolver.single) }
|
|
|
|
end
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
describe 'members field' do
|
|
|
|
subject { described_class.fields['projectMembers'] }
|
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
it { is_expected.to have_graphql_type(Types::MemberInterface.connection_type) }
|
2020-06-23 00:09:42 +05:30
|
|
|
it { is_expected.to have_graphql_resolver(Resolvers::ProjectMembersResolver) }
|
|
|
|
end
|
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
describe 'boards field' do
|
|
|
|
subject { described_class.fields['boards'] }
|
|
|
|
|
|
|
|
it { is_expected.to have_graphql_type(Types::BoardType.connection_type) }
|
|
|
|
end
|
2020-04-22 19:07:51 +05:30
|
|
|
|
|
|
|
describe 'jira_imports field' do
|
|
|
|
subject { described_class.fields['jiraImports'] }
|
|
|
|
|
|
|
|
it { is_expected.to have_graphql_type(Types::JiraImportType.connection_type) }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'services field' do
|
|
|
|
subject { described_class.fields['services'] }
|
|
|
|
|
|
|
|
it { is_expected.to have_graphql_type(Types::Projects::ServiceType.connection_type) }
|
|
|
|
end
|
2020-05-24 23:13:21 +05:30
|
|
|
|
|
|
|
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
|
2020-06-23 00:09:42 +05:30
|
|
|
|
|
|
|
describe 'container expiration policy field' do
|
|
|
|
subject { described_class.fields['containerExpirationPolicy'] }
|
|
|
|
|
|
|
|
it { is_expected.to have_graphql_type(Types::ContainerExpirationPolicyType) }
|
|
|
|
end
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
describe 'terraform states field' do
|
|
|
|
subject { described_class.fields['terraformStates'] }
|
|
|
|
|
|
|
|
it { is_expected.to have_graphql_type(Types::Terraform::StateType.connection_type) }
|
|
|
|
it { is_expected.to have_graphql_resolver(Resolvers::Terraform::StatesResolver) }
|
|
|
|
end
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
it_behaves_like 'a GraphQL type with labels'
|
2021-02-22 17:27:13 +05:30
|
|
|
|
|
|
|
describe 'jira_imports' do
|
|
|
|
subject { resolve_field(:jira_imports, project) }
|
|
|
|
|
|
|
|
let_it_be(:project) { create(:project, :public) }
|
|
|
|
|
|
|
|
context 'when project has Jira imports' do
|
|
|
|
let_it_be(:jira_import1) { create(:jira_import_state, :finished, project: project, jira_project_key: 'AA', created_at: 2.days.ago) }
|
|
|
|
let_it_be(:jira_import2) { create(:jira_import_state, :finished, project: project, jira_project_key: 'BB', created_at: 5.days.ago) }
|
|
|
|
|
|
|
|
it 'retrieves the imports' do
|
|
|
|
expect(subject).to contain_exactly(jira_import1, jira_import2)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when project does not have Jira imports' do
|
|
|
|
it 'returns an empty result' do
|
|
|
|
expect(subject).to be_empty
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'pipeline_analytics field' do
|
|
|
|
subject { described_class.fields['pipelineAnalytics'] }
|
|
|
|
|
|
|
|
it { is_expected.to have_graphql_type(Types::Ci::AnalyticsType) }
|
|
|
|
it { is_expected.to have_graphql_resolver(Resolvers::ProjectPipelineStatisticsResolver) }
|
|
|
|
end
|
2018-11-08 19:23:39 +05:30
|
|
|
end
|