diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-06 21:08:40 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-06 21:08:40 +0300 |
commit | 1f5e09ed6082d079dfebef92f69630c10f78c844 (patch) | |
tree | 5ef925fe6d08f2a042e47c2a9e1c40238ca8211c /spec/policies | |
parent | 78782cd1eb5273265668ca3e438bb8cbb1344004 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/policies')
-rw-r--r-- | spec/policies/ci/build_policy_spec.rb | 30 | ||||
-rw-r--r-- | spec/policies/ci/pipeline_policy_spec.rb | 18 | ||||
-rw-r--r-- | spec/policies/ci/pipeline_schedule_policy_spec.rb | 12 | ||||
-rw-r--r-- | spec/policies/environment_policy_spec.rb | 3 | ||||
-rw-r--r-- | spec/policies/group_policy_spec.rb | 5 |
5 files changed, 22 insertions, 46 deletions
diff --git a/spec/policies/ci/build_policy_spec.rb b/spec/policies/ci/build_policy_spec.rb index fee4d76ca8f..77cfcab5c3e 100644 --- a/spec/policies/ci/build_policy_spec.rb +++ b/spec/policies/ci/build_policy_spec.rb @@ -121,8 +121,7 @@ RSpec.describe Ci::BuildPolicy do context 'when no one can push or merge to the branch' do before do - create(:protected_branch, :no_one_can_push, - name: build.ref, project: project) + create(:protected_branch, :no_one_can_push, name: build.ref, project: project) end it 'does not include ability to update build' do @@ -132,8 +131,7 @@ RSpec.describe Ci::BuildPolicy do context 'when developers can push to the branch' do before do - create(:protected_branch, :developers_can_merge, - name: build.ref, project: project) + create(:protected_branch, :developers_can_merge, name: build.ref, project: project) end it 'includes ability to update build' do @@ -143,8 +141,7 @@ RSpec.describe Ci::BuildPolicy do context 'when no one can create the tag' do before do - create(:protected_tag, :no_one_can_create, - name: build.ref, project: project) + create(:protected_tag, :no_one_can_create, name: build.ref, project: project) build.update!(tag: true) end @@ -156,8 +153,7 @@ RSpec.describe Ci::BuildPolicy do context 'when no one can create the tag but it is not a tag' do before do - create(:protected_tag, :no_one_can_create, - name: build.ref, project: project) + create(:protected_tag, :no_one_can_create, name: build.ref, project: project) end it 'includes ability to update build' do @@ -181,8 +177,7 @@ RSpec.describe Ci::BuildPolicy do context 'when the build was created for a protected ref' do before do - create(:protected_branch, :developers_can_push, - name: build.ref, project: project) + create(:protected_branch, :developers_can_push, name: build.ref, project: project) end it { expect(policy).to be_disallowed :erase_build } @@ -204,8 +199,7 @@ RSpec.describe Ci::BuildPolicy do let(:owner) { user } before do - create(:protected_branch, :no_one_can_push, :no_one_can_merge, - name: build.ref, project: project) + create(:protected_branch, :no_one_can_push, :no_one_can_merge, name: build.ref, project: project) end it { expect(policy).to be_disallowed :erase_build } @@ -219,8 +213,7 @@ RSpec.describe Ci::BuildPolicy do context 'when maintainers can push to the branch' do before do - create(:protected_branch, :maintainers_can_push, - name: build.ref, project: project) + create(:protected_branch, :maintainers_can_push, name: build.ref, project: project) end context 'when the build was created by the maintainer' do @@ -240,8 +233,7 @@ RSpec.describe Ci::BuildPolicy do let(:owner) { user } before do - create(:protected_branch, :no_one_can_push, :no_one_can_merge, - name: build.ref, project: project) + create(:protected_branch, :no_one_can_push, :no_one_can_merge, name: build.ref, project: project) end it { expect(policy).to be_disallowed :erase_build } @@ -257,8 +249,7 @@ RSpec.describe Ci::BuildPolicy do context 'when the build was created for a protected branch' do before do - create(:protected_branch, :developers_can_push, - name: build.ref, project: project) + create(:protected_branch, :developers_can_push, name: build.ref, project: project) end it { expect(policy).to be_allowed :erase_build } @@ -266,8 +257,7 @@ RSpec.describe Ci::BuildPolicy do context 'when the build was created for a protected tag' do before do - create(:protected_tag, :developers_can_create, - name: build.ref, project: project) + create(:protected_tag, :developers_can_create, name: build.ref, project: project) end it { expect(policy).to be_allowed :erase_build } diff --git a/spec/policies/ci/pipeline_policy_spec.rb b/spec/policies/ci/pipeline_policy_spec.rb index b68bb966820..8a5b80e3051 100644 --- a/spec/policies/ci/pipeline_policy_spec.rb +++ b/spec/policies/ci/pipeline_policy_spec.rb @@ -20,8 +20,7 @@ RSpec.describe Ci::PipelinePolicy, :models do context 'when no one can push or merge to the branch' do before do - create(:protected_branch, :no_one_can_push, - name: pipeline.ref, project: project) + create(:protected_branch, :no_one_can_push, name: pipeline.ref, project: project) end it 'does not include ability to update pipeline' do @@ -31,8 +30,7 @@ RSpec.describe Ci::PipelinePolicy, :models do context 'when developers can push to the branch' do before do - create(:protected_branch, :developers_can_merge, - name: pipeline.ref, project: project) + create(:protected_branch, :developers_can_merge, name: pipeline.ref, project: project) end it 'includes ability to update pipeline' do @@ -42,8 +40,7 @@ RSpec.describe Ci::PipelinePolicy, :models do context 'when no one can create the tag' do before do - create(:protected_tag, :no_one_can_create, - name: pipeline.ref, project: project) + create(:protected_tag, :no_one_can_create, name: pipeline.ref, project: project) pipeline.update!(tag: true) end @@ -55,8 +52,7 @@ RSpec.describe Ci::PipelinePolicy, :models do context 'when no one can create the tag but it is not a tag' do before do - create(:protected_tag, :no_one_can_create, - name: pipeline.ref, project: project) + create(:protected_tag, :no_one_can_create, name: pipeline.ref, project: project) end it 'includes ability to update pipeline' do @@ -119,8 +115,7 @@ RSpec.describe Ci::PipelinePolicy, :models do before do project.add_developer(user) - create(:protected_branch, :developers_can_merge, - name: pipeline.ref, project: project) + create(:protected_branch, :developers_can_merge, name: pipeline.ref, project: project) end it 'is enabled' do @@ -133,8 +128,7 @@ RSpec.describe Ci::PipelinePolicy, :models do before do project.add_developer(user) - create(:protected_branch, :developers_can_merge, - name: pipeline.ref, project: project) + create(:protected_branch, :developers_can_merge, name: pipeline.ref, project: project) end it 'is disabled' do diff --git a/spec/policies/ci/pipeline_schedule_policy_spec.rb b/spec/policies/ci/pipeline_schedule_policy_spec.rb index 92ad37145c0..7025eda1ba1 100644 --- a/spec/policies/ci/pipeline_schedule_policy_spec.rb +++ b/spec/policies/ci/pipeline_schedule_policy_spec.rb @@ -19,8 +19,7 @@ RSpec.describe Ci::PipelineSchedulePolicy, :models, :clean_gitlab_redis_cache do context 'when no one can push or merge to the branch' do before do - create(:protected_branch, :no_one_can_push, - name: pipeline_schedule.ref, project: project) + create(:protected_branch, :no_one_can_push, name: pipeline_schedule.ref, project: project) end it 'does not include ability to play pipeline schedule' do @@ -30,8 +29,7 @@ RSpec.describe Ci::PipelineSchedulePolicy, :models, :clean_gitlab_redis_cache do context 'when developers can push to the branch' do before do - create(:protected_branch, :developers_can_merge, - name: pipeline_schedule.ref, project: project) + create(:protected_branch, :developers_can_merge, name: pipeline_schedule.ref, project: project) end it 'includes ability to update pipeline' do @@ -45,8 +43,7 @@ RSpec.describe Ci::PipelineSchedulePolicy, :models, :clean_gitlab_redis_cache do before do pipeline_schedule.update!(ref: tag) - create(:protected_tag, :no_one_can_create, - name: pipeline_schedule.ref, project: project) + create(:protected_tag, :no_one_can_create, name: pipeline_schedule.ref, project: project) end it 'does not include ability to play pipeline schedule' do @@ -56,8 +53,7 @@ RSpec.describe Ci::PipelineSchedulePolicy, :models, :clean_gitlab_redis_cache do context 'when no one can create the tag but it is not a tag' do before do - create(:protected_tag, :no_one_can_create, - name: pipeline_schedule.ref, project: project) + create(:protected_tag, :no_one_can_create, name: pipeline_schedule.ref, project: project) end it 'includes ability to play pipeline schedule' do diff --git a/spec/policies/environment_policy_spec.rb b/spec/policies/environment_policy_spec.rb index 701fc7ac9ae..f0957ff5cc9 100644 --- a/spec/policies/environment_policy_spec.rb +++ b/spec/policies/environment_policy_spec.rb @@ -50,8 +50,7 @@ RSpec.describe EnvironmentPolicy do with_them do before do project.add_member(user, access_level) unless access_level.nil? - create(:protected_branch, :no_one_can_push, - name: 'master', project: project) + create(:protected_branch, :no_one_can_push, name: 'master', project: project) end it { expect(policy).to be_disallowed :stop_environment } diff --git a/spec/policies/group_policy_spec.rb b/spec/policies/group_policy_spec.rb index 003ca2512dc..1103ea4eaad 100644 --- a/spec/policies/group_policy_spec.rb +++ b/spec/policies/group_policy_spec.rb @@ -735,10 +735,7 @@ RSpec.describe GroupPolicy, feature_category: :system_access do it_behaves_like 'clusterable policies' do let(:clusterable) { create(:group, :crm_enabled) } let(:cluster) do - create(:cluster, - :provided_by_gcp, - :group, - groups: [clusterable]) + create(:cluster, :provided_by_gcp, :group, groups: [clusterable]) end end |