Commit d92d9b5e authored by Steve Abrams's avatar Steve Abrams Committed by Ash McKenzie

Add default values to container_expiration_policies_helper

parent b539ef7a
...@@ -3,19 +3,25 @@ ...@@ -3,19 +3,25 @@
module ContainerExpirationPoliciesHelper module ContainerExpirationPoliciesHelper
def cadence_options def cadence_options
ContainerExpirationPolicy.cadence_options.map do |key, val| 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
end end
def keep_n_options def keep_n_options
ContainerExpirationPolicy.keep_n_options.map do |key, val| 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
end end
def older_than_options def older_than_options
ContainerExpirationPolicy.older_than_options.map do |key, val| 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 end
end end
...@@ -8,7 +8,7 @@ describe ContainerExpirationPoliciesHelper do ...@@ -8,7 +8,7 @@ describe ContainerExpirationPoliciesHelper do
expected_result = [ expected_result = [
{ key: 1, label: '1 tag per image name' }, { key: 1, label: '1 tag per image name' },
{ key: 5, label: '5 tags 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: 25, label: '25 tags per image name' },
{ key: 50, label: '50 tags per image name' }, { key: 50, label: '50 tags per image name' },
{ key: 100, label: '100 tags per image name' } { key: 100, label: '100 tags per image name' }
...@@ -21,7 +21,7 @@ describe ContainerExpirationPoliciesHelper do ...@@ -21,7 +21,7 @@ describe ContainerExpirationPoliciesHelper do
describe '#cadence_options' do describe '#cadence_options' do
it 'returns cadence options formatted for dropdown usage' do it 'returns cadence options formatted for dropdown usage' do
expected_result = [ expected_result = [
{ key: '1d', label: 'Every day' }, { key: '1d', label: 'Every day', default: true },
{ key: '7d', label: 'Every week' }, { key: '7d', label: 'Every week' },
{ key: '14d', label: 'Every two weeks' }, { key: '14d', label: 'Every two weeks' },
{ key: '1month', label: 'Every month' }, { key: '1month', label: 'Every month' },
...@@ -37,7 +37,7 @@ describe ContainerExpirationPoliciesHelper do ...@@ -37,7 +37,7 @@ describe ContainerExpirationPoliciesHelper do
expected_result = [ expected_result = [
{ key: '7d', label: '7 days until tags are automatically removed' }, { key: '7d', label: '7 days until tags are automatically removed' },
{ key: '14d', label: '14 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' } { 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