diff options
author | Rémy Coutable <remy@rymai.me> | 2018-06-20 12:49:53 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-06-20 12:49:53 +0000 |
commit | b349c01c6a71ac1f486b8ee86ce96ef48ac04ed8 (patch) | |
tree | 86f60055392a492ea007688b2ef2347a029f2f16 | |
parent | 1b76f1dcebfad23485c77607ea1fd59548cac96b (diff) | |
parent | f61dcfe816ce28427622e5a314e972ae4b33b9ea (diff) | |
download | gitlab-ce-b349c01c6a71ac1f486b8ee86ce96ef48ac04ed8.tar.gz |
Merge branch '47631-operations-kubernetes-option-is-always-visible-when-repository-or-builds-are-disabled' into 'master'
Operations and Kubernetes option should be omitted when repository or builds are disabled
Closes #47631
See merge request gitlab-org/gitlab-ce!19835
3 files changed, 44 insertions, 0 deletions
diff --git a/app/policies/project_policy.rb b/app/policies/project_policy.rb index 8ea5435d740..199bcf92b21 100644 --- a/app/policies/project_policy.rb +++ b/app/policies/project_policy.rb @@ -297,6 +297,7 @@ class ProjectPolicy < BasePolicy prevent(*create_read_update_admin_destroy(:build)) prevent(*create_read_update_admin_destroy(:pipeline_schedule)) prevent(*create_read_update_admin_destroy(:environment)) + prevent(*create_read_update_admin_destroy(:cluster)) prevent(*create_read_update_admin_destroy(:deployment)) end diff --git a/changelogs/unreleased/47631-operations-kubernetes-option-is-always-visible-when-repository-or-builds-are-disabled.yml b/changelogs/unreleased/47631-operations-kubernetes-option-is-always-visible-when-repository-or-builds-are-disabled.yml new file mode 100644 index 00000000000..5c23b3ef320 --- /dev/null +++ b/changelogs/unreleased/47631-operations-kubernetes-option-is-always-visible-when-repository-or-builds-are-disabled.yml @@ -0,0 +1,5 @@ +--- +title: Omits operartions and kubernetes item from project sidebar when repository or builds are disabled +merge_request: 19835 +author: +type: fixed diff --git a/spec/policies/project_policy_spec.rb b/spec/policies/project_policy_spec.rb index 6ac151f92f3..6d4676c25a5 100644 --- a/spec/policies/project_policy_spec.rb +++ b/spec/policies/project_policy_spec.rb @@ -151,6 +151,44 @@ describe ProjectPolicy do end end + context 'builds feature' do + subject { described_class.new(owner, project) } + + it 'disallows all permissions when the feature is disabled' do + project.project_feature.update(builds_access_level: ProjectFeature::DISABLED) + + builds_permissions = [ + :create_pipeline, :update_pipeline, :admin_pipeline, :destroy_pipeline, + :create_build, :read_build, :update_build, :admin_build, :destroy_build, + :create_pipeline_schedule, :read_pipeline_schedule, :update_pipeline_schedule, :admin_pipeline_schedule, :destroy_pipeline_schedule, + :create_environment, :read_environment, :update_environment, :admin_environment, :destroy_environment, + :create_cluster, :read_cluster, :update_cluster, :admin_cluster, :destroy_cluster, + :create_deployment, :read_deployment, :update_deployment, :admin_deployment, :destroy_deployment + ] + + expect_disallowed(*builds_permissions) + end + end + + context 'repository feature' do + subject { described_class.new(owner, project) } + + it 'disallows all permissions when the feature is disabled' do + project.project_feature.update(repository_access_level: ProjectFeature::DISABLED) + + repository_permissions = [ + :create_pipeline, :update_pipeline, :admin_pipeline, :destroy_pipeline, + :create_build, :read_build, :update_build, :admin_build, :destroy_build, + :create_pipeline_schedule, :read_pipeline_schedule, :update_pipeline_schedule, :admin_pipeline_schedule, :destroy_pipeline_schedule, + :create_environment, :read_environment, :update_environment, :admin_environment, :destroy_environment, + :create_cluster, :read_cluster, :update_cluster, :admin_cluster, :destroy_cluster, + :create_deployment, :read_deployment, :update_deployment, :admin_deployment, :destroy_deployment + ] + + expect_disallowed(*repository_permissions) + end + end + shared_examples 'archived project policies' do let(:feature_write_abilities) do described_class::READONLY_FEATURES_WHEN_ARCHIVED.flat_map do |feature| |