diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /spec/models/container_expiration_policy_spec.rb | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'spec/models/container_expiration_policy_spec.rb')
-rw-r--r-- | spec/models/container_expiration_policy_spec.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/models/container_expiration_policy_spec.rb b/spec/models/container_expiration_policy_spec.rb index c22362ed5d4..588685b04bf 100644 --- a/spec/models/container_expiration_policy_spec.rb +++ b/spec/models/container_expiration_policy_spec.rb @@ -37,6 +37,37 @@ RSpec.describe ContainerExpirationPolicy, type: :model do it { is_expected.to allow_value(nil).for(:keep_n) } it { is_expected.not_to allow_value('foo').for(:keep_n) } end + + context 'with a set of regexps' do + valid_regexps = %w[master .* v.+ v10.1.* (?:v.+|master|release)] + invalid_regexps = ['[', '(?:v.+|master|release'] + + valid_regexps.each do |valid_regexp| + it { is_expected.to allow_value(valid_regexp).for(:name_regex) } + it { is_expected.to allow_value(valid_regexp).for(:name_regex_keep) } + end + + invalid_regexps.each do |invalid_regexp| + it { is_expected.not_to allow_value(invalid_regexp).for(:name_regex) } + it { is_expected.not_to allow_value(invalid_regexp).for(:name_regex_keep) } + end + + context 'with a disabled container expiration policy' do + let_it_be(:container_expiration_policy) { create(:container_expiration_policy, :disabled) } + + subject { container_expiration_policy } + + valid_regexps.each do |valid_regexp| + it { is_expected.to allow_value(valid_regexp).for(:name_regex) } + it { is_expected.to allow_value(valid_regexp).for(:name_regex_keep) } + end + + invalid_regexps.each do |invalid_regexp| + it { is_expected.to allow_value(invalid_regexp).for(:name_regex) } + it { is_expected.to allow_value(invalid_regexp).for(:name_regex_keep) } + end + end + end end describe '.preloaded' do @@ -72,4 +103,14 @@ RSpec.describe ContainerExpirationPolicy, type: :model do end end end + + describe '#disable!' do + let_it_be(:container_expiration_policy) { create(:container_expiration_policy) } + + subject { container_expiration_policy.disable! } + + it 'disables the container expiration policy' do + expect { subject }.to change { container_expiration_policy.reload.enabled }.from(true).to(false) + end + end end |