Commit 685afce7 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch '18792-update-graphql-api' into 'master'

Update GraphQL project type field container_registry_enabled [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!66059
parents d112e364 5370ae99
...@@ -59,8 +59,6 @@ module Types ...@@ -59,8 +59,6 @@ module Types
field :visibility, GraphQL::STRING_TYPE, null: true, field :visibility, GraphQL::STRING_TYPE, null: true,
description: 'Visibility of the project.' description: 'Visibility of the project.'
field :container_registry_enabled, GraphQL::BOOLEAN_TYPE, null: true,
description: 'Indicates if the project stores Docker container images in a container registry.'
field :shared_runners_enabled, GraphQL::BOOLEAN_TYPE, null: true, field :shared_runners_enabled, GraphQL::BOOLEAN_TYPE, null: true,
description: 'Indicates if shared runners are enabled for the project.' description: 'Indicates if shared runners are enabled for the project.'
field :lfs_enabled, GraphQL::BOOLEAN_TYPE, null: true, field :lfs_enabled, GraphQL::BOOLEAN_TYPE, null: true,
...@@ -77,9 +75,15 @@ module Types ...@@ -77,9 +75,15 @@ module Types
field :avatar_url, GraphQL::STRING_TYPE, null: true, calls_gitaly: true, field :avatar_url, GraphQL::STRING_TYPE, null: true, calls_gitaly: true,
description: 'URL to avatar image file of the project.' description: 'URL to avatar image file of the project.'
%i[issues merge_requests wiki snippets].each do |feature| {
issues: "Issues are",
merge_requests: "Merge Requests are",
wiki: 'Wikis are',
snippets: 'Snippets are',
container_registry: 'Container Registry is'
}.each do |feature, name_string|
field "#{feature}_enabled", GraphQL::BOOLEAN_TYPE, null: true, field "#{feature}_enabled", GraphQL::BOOLEAN_TYPE, null: true,
description: "Indicates if #{feature.to_s.titleize.pluralize} are enabled for the current user" description: "Indicates if #{name_string} enabled for the current user"
define_method "#{feature}_enabled" do define_method "#{feature}_enabled" do
object.feature_available?(feature, context[:current_user]) object.feature_available?(feature, context[:current_user])
......
...@@ -11402,7 +11402,7 @@ Represents vulnerability finding of a security report on the pipeline. ...@@ -11402,7 +11402,7 @@ Represents vulnerability finding of a security report on the pipeline.
| <a id="projectcodecoveragesummary"></a>`codeCoverageSummary` | [`CodeCoverageSummary`](#codecoveragesummary) | Code coverage summary associated with the project. | | <a id="projectcodecoveragesummary"></a>`codeCoverageSummary` | [`CodeCoverageSummary`](#codecoveragesummary) | Code coverage summary associated with the project. |
| <a id="projectcomplianceframeworks"></a>`complianceFrameworks` | [`ComplianceFrameworkConnection`](#complianceframeworkconnection) | Compliance frameworks associated with the project. (see [Connections](#connections)) | | <a id="projectcomplianceframeworks"></a>`complianceFrameworks` | [`ComplianceFrameworkConnection`](#complianceframeworkconnection) | Compliance frameworks associated with the project. (see [Connections](#connections)) |
| <a id="projectcontainerexpirationpolicy"></a>`containerExpirationPolicy` | [`ContainerExpirationPolicy`](#containerexpirationpolicy) | The container expiration policy of the project. | | <a id="projectcontainerexpirationpolicy"></a>`containerExpirationPolicy` | [`ContainerExpirationPolicy`](#containerexpirationpolicy) | The container expiration policy of the project. |
| <a id="projectcontainerregistryenabled"></a>`containerRegistryEnabled` | [`Boolean`](#boolean) | Indicates if the project stores Docker container images in a container registry. | | <a id="projectcontainerregistryenabled"></a>`containerRegistryEnabled` | [`Boolean`](#boolean) | Indicates if Container Registry is enabled for the current user. |
| <a id="projectcontainerrepositoriescount"></a>`containerRepositoriesCount` | [`Int!`](#int) | Number of container repositories in the project. | | <a id="projectcontainerrepositoriescount"></a>`containerRepositoriesCount` | [`Int!`](#int) | Number of container repositories in the project. |
| <a id="projectcreatedat"></a>`createdAt` | [`Time`](#time) | Timestamp of the project creation. | | <a id="projectcreatedat"></a>`createdAt` | [`Time`](#time) | Timestamp of the project creation. |
| <a id="projectdastprofiles"></a>`dastProfiles` | [`DastProfileConnection`](#dastprofileconnection) | DAST Profiles associated with the project. (see [Connections](#connections)) | | <a id="projectdastprofiles"></a>`dastProfiles` | [`DastProfileConnection`](#dastprofileconnection) | DAST Profiles associated with the project. (see [Connections](#connections)) |
......
...@@ -39,6 +39,61 @@ RSpec.describe GitlabSchema.types['Project'] do ...@@ -39,6 +39,61 @@ RSpec.describe GitlabSchema.types['Project'] do
expect(described_class).to include_graphql_fields(*expected_fields) expect(described_class).to include_graphql_fields(*expected_fields)
end end
describe 'container_registry_enabled' do
let_it_be(:project, reload: true) { create(:project, :public) }
let_it_be(:user) { create(:user) }
let(:query) do
%(
query {
project(fullPath: "#{project.full_path}") {
containerRegistryEnabled
}
}
)
end
subject { GitlabSchema.execute(query, context: { current_user: user }).as_json }
context 'with `enabled` visibility' do
before do
project.project_feature.update_column(:container_registry_access_level, ProjectFeature::ENABLED)
end
context 'with non member user' do
it 'returns true' do
expect(subject.dig('data', 'project', 'containerRegistryEnabled')).to eq(true)
end
end
end
context 'with `private` visibility' do
before do
project.project_feature.update_column(:container_registry_access_level, ProjectFeature::PRIVATE)
end
context 'with reporter user' do
before do
project.add_reporter(user)
end
it 'returns true' do
expect(subject.dig('data', 'project', 'containerRegistryEnabled')).to eq(true)
end
end
context 'with guest user' do
before do
project.add_guest(user)
end
it 'returns false' do
expect(subject.dig('data', 'project', 'containerRegistryEnabled')).to eq(false)
end
end
end
end
describe 'sast_ci_configuration' do describe 'sast_ci_configuration' do
let_it_be(:project) { create(:project) } let_it_be(:project) { create(:project) }
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment