Welcome to mirror list, hosted at ThFree Co, Russian Federation.

container_expiration_policy_policy_spec.rb « policies « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4b39dd8dace08220c2439d469e4a103541510851 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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