diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-11 00:09:04 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-11 00:09:04 +0300 |
commit | 8cd9a013792172f8d64eba8f327e2dadd71efffb (patch) | |
tree | c9510d854278cb1846ed1e3b2f4019c4f1a4f3ad /spec/policies | |
parent | 56b3925584320c4406b7cb961fbe19ff9f9c41d4 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/policies')
-rw-r--r-- | spec/policies/container_expiration_policy_policy_spec.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/policies/container_expiration_policy_policy_spec.rb b/spec/policies/container_expiration_policy_policy_spec.rb new file mode 100644 index 00000000000..4b39dd8dace --- /dev/null +++ b/spec/policies/container_expiration_policy_policy_spec.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe ContainerExpirationPolicyPolicy do + using RSpec::Parameterized::TableSyntax + + let_it_be(:user) { create(:user) } + let_it_be(:project, reload: true) { create(:project) } + + subject { described_class.new(user, project.container_expiration_policy) } + + where(:user_type, :allowed_to_destroy_container_image) do + :anonymous | false + :guest | false + :developer | false + :maintainer | true + end + + with_them do + context "for user type #{params[:user_type]}" do + before do + project.public_send("add_#{user_type}", user) unless user_type == :anonymous + end + + if params[:allowed_to_destroy_container_image] + it { is_expected.to be_allowed(:admin_container_image) } + else + it { is_expected.not_to be_allowed(:admin_container_image) } + end + end + end +end |