summaryrefslogtreecommitdiff
path: root/spec/models/container_expiration_policy_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/container_expiration_policy_spec.rb')
-rw-r--r--spec/models/container_expiration_policy_spec.rb41
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
new file mode 100644
index 00000000000..1ce76490448
--- /dev/null
+++ b/spec/models/container_expiration_policy_spec.rb
@@ -0,0 +1,41 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe ContainerExpirationPolicy, type: :model do
+ describe 'relationships' do
+ it { is_expected.to belong_to(:project) }
+ end
+
+ describe 'validations' do
+ it { is_expected.to validate_presence_of(:project) }
+
+ describe '#enabled' do
+ it { is_expected.to allow_value(true).for(:enabled) }
+ it { is_expected.to allow_value(false).for(:enabled) }
+ it { is_expected.not_to allow_value(nil).for(:enabled) }
+ end
+
+ describe '#cadence' do
+ it { is_expected.to validate_presence_of(:cadence) }
+
+ it { is_expected.to allow_value('1d').for(:cadence) }
+ it { is_expected.to allow_value('1month').for(:cadence) }
+ it { is_expected.not_to allow_value('123asdf').for(:cadence) }
+ it { is_expected.not_to allow_value(nil).for(:cadence) }
+ end
+
+ describe '#older_than' do
+ it { is_expected.to allow_value('7d').for(:older_than) }
+ it { is_expected.to allow_value('14d').for(:older_than) }
+ it { is_expected.to allow_value(nil).for(:older_than) }
+ it { is_expected.not_to allow_value('123asdf').for(:older_than) }
+ end
+
+ describe '#keep_n' do
+ it { is_expected.to allow_value(10).for(:keep_n) }
+ it { is_expected.to allow_value(nil).for(:keep_n) }
+ it { is_expected.not_to allow_value('foo').for(:keep_n) }
+ end
+ end
+end