Commit 268d1ff6 authored by Ash McKenzie's avatar Ash McKenzie

Merge branch '15398-default-values' into 'master'

Add default values to container_expiration_policies_helper

See merge request gitlab-org/gitlab!21849
parents b539ef7a d92d9b5e
......@@ -3,19 +3,25 @@
module ContainerExpirationPoliciesHelper
def cadence_options
ContainerExpirationPolicy.cadence_options.map do |key, val|
{ key: key.to_s, label: val }
{ key: key.to_s, label: val }.tap do |base|
base[:default] = true if key.to_s == '1d'
end
end
end
def keep_n_options
ContainerExpirationPolicy.keep_n_options.map do |key, val|
{ key: key, label: val }
{ key: key, label: val }.tap do |base|
base[:default] = true if key == 10
end
end
end
def older_than_options
ContainerExpirationPolicy.older_than_options.map do |key, val|
{ key: key.to_s, label: val }
{ key: key.to_s, label: val }.tap do |base|
base[:default] = true if key.to_s == '30d'
end
end
end
end
......@@ -8,7 +8,7 @@ describe ContainerExpirationPoliciesHelper do
expected_result = [
{ key: 1, label: '1 tag per image name' },
{ key: 5, label: '5 tags per image name' },
{ key: 10, label: '10 tags per image name' },
{ key: 10, label: '10 tags per image name', default: true },
{ key: 25, label: '25 tags per image name' },
{ key: 50, label: '50 tags per image name' },
{ key: 100, label: '100 tags per image name' }
......@@ -21,7 +21,7 @@ describe ContainerExpirationPoliciesHelper do
describe '#cadence_options' do
it 'returns cadence options formatted for dropdown usage' do
expected_result = [
{ key: '1d', label: 'Every day' },
{ key: '1d', label: 'Every day', default: true },
{ key: '7d', label: 'Every week' },
{ key: '14d', label: 'Every two weeks' },
{ key: '1month', label: 'Every month' },
......@@ -37,7 +37,7 @@ describe ContainerExpirationPoliciesHelper do
expected_result = [
{ key: '7d', label: '7 days until tags are automatically removed' },
{ key: '14d', label: '14 days until tags are automatically removed' },
{ key: '30d', label: '30 days until tags are automatically removed' },
{ key: '30d', label: '30 days until tags are automatically removed', default: true },
{ key: '90d', label: '90 days until tags are automatically removed' }
]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment