2019-12-11 07:08:10 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 05:08:32 -04:00
|
|
|
RSpec.describe ContainerExpirationPoliciesHelper do
|
2019-12-11 07:08:10 -05:00
|
|
|
describe '#keep_n_options' do
|
|
|
|
it 'returns keep_n options formatted for dropdown usage' do
|
|
|
|
expected_result = [
|
|
|
|
{ key: 1, label: '1 tag per image name' },
|
|
|
|
{ key: 5, label: '5 tags per image name' },
|
2019-12-20 04:24:38 -05:00
|
|
|
{ key: 10, label: '10 tags per image name', default: true },
|
2019-12-11 07:08:10 -05:00
|
|
|
{ key: 25, label: '25 tags per image name' },
|
|
|
|
{ key: 50, label: '50 tags per image name' },
|
|
|
|
{ key: 100, label: '100 tags per image name' }
|
|
|
|
]
|
|
|
|
|
|
|
|
expect(helper.keep_n_options).to eq(expected_result)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#cadence_options' do
|
|
|
|
it 'returns cadence options formatted for dropdown usage' do
|
|
|
|
expected_result = [
|
2019-12-20 04:24:38 -05:00
|
|
|
{ key: '1d', label: 'Every day', default: true },
|
2019-12-11 07:08:10 -05:00
|
|
|
{ key: '7d', label: 'Every week' },
|
|
|
|
{ key: '14d', label: 'Every two weeks' },
|
|
|
|
{ key: '1month', label: 'Every month' },
|
|
|
|
{ key: '3month', label: 'Every three months' }
|
|
|
|
]
|
|
|
|
|
|
|
|
expect(helper.cadence_options).to eq(expected_result)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#older_than_options' do
|
|
|
|
it 'returns older_than options formatted for dropdown usage' do
|
|
|
|
expected_result = [
|
|
|
|
{ key: '7d', label: '7 days until tags are automatically removed' },
|
|
|
|
{ key: '14d', label: '14 days until tags are automatically removed' },
|
2020-04-02 14:08:11 -04:00
|
|
|
{ key: '30d', label: '30 days until tags are automatically removed' },
|
2021-09-29 08:11:22 -04:00
|
|
|
{ key: '60d', label: '60 days until tags are automatically removed' },
|
2020-04-02 14:08:11 -04:00
|
|
|
{ key: '90d', label: '90 days until tags are automatically removed', default: true }
|
2019-12-11 07:08:10 -05:00
|
|
|
]
|
|
|
|
|
|
|
|
expect(helper.older_than_options).to eq(expected_result)
|
|
|
|
end
|
|
|
|
end
|
2020-10-12 11:08:32 -04:00
|
|
|
|
|
|
|
describe '#container_expiration_policies_historic_entry_enabled?' do
|
|
|
|
let_it_be(:project) { build_stubbed(:project) }
|
|
|
|
|
2022-03-04 22:19:17 -05:00
|
|
|
subject { helper.container_expiration_policies_historic_entry_enabled? }
|
|
|
|
|
|
|
|
context 'when the application setting is enabled' do
|
|
|
|
before do
|
|
|
|
stub_application_setting(container_expiration_policies_enable_historic_entries: true)
|
|
|
|
end
|
2020-10-12 11:08:32 -04:00
|
|
|
|
2022-03-04 22:19:17 -05:00
|
|
|
it { is_expected.to be_truthy }
|
2020-10-12 11:08:32 -04:00
|
|
|
end
|
|
|
|
|
2022-03-04 22:19:17 -05:00
|
|
|
context 'when the application setting is disabled' do
|
2020-10-12 11:08:32 -04:00
|
|
|
before do
|
2022-03-04 22:19:17 -05:00
|
|
|
stub_application_setting(container_expiration_policies_enable_historic_entries: false)
|
2020-10-12 11:08:32 -04:00
|
|
|
end
|
|
|
|
|
2022-03-04 22:19:17 -05:00
|
|
|
it { is_expected.to be_falsey }
|
2020-10-12 11:08:32 -04:00
|
|
|
end
|
|
|
|
end
|
2019-12-11 07:08:10 -05:00
|
|
|
end
|