summaryrefslogtreecommitdiff
path: root/spec/policies/container_expiration_policy_policy_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/policies/container_expiration_policy_policy_spec.rb')
-rw-r--r--spec/policies/container_expiration_policy_policy_spec.rb33
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