diff options
Diffstat (limited to 'spec/helpers')
-rw-r--r-- | spec/helpers/container_expiration_policies_helper_spec.rb | 47 | ||||
-rw-r--r-- | spec/helpers/nav_helper_spec.rb | 17 |
2 files changed, 60 insertions, 4 deletions
diff --git a/spec/helpers/container_expiration_policies_helper_spec.rb b/spec/helpers/container_expiration_policies_helper_spec.rb new file mode 100644 index 00000000000..3eb1234d82b --- /dev/null +++ b/spec/helpers/container_expiration_policies_helper_spec.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe ContainerExpirationPoliciesHelper do + 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' }, + { key: 10, label: '10 tags per image name' }, + { 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 = [ + { key: '1d', label: 'Every day' }, + { 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' }, + { key: '30d', label: '30 days until tags are automatically removed' }, + { key: '90d', label: '90 days until tags are automatically removed' } + ] + + expect(helper.older_than_options).to eq(expected_result) + end + end +end diff --git a/spec/helpers/nav_helper_spec.rb b/spec/helpers/nav_helper_spec.rb index 882a125a0da..8d7572c5b5f 100644 --- a/spec/helpers/nav_helper_spec.rb +++ b/spec/helpers/nav_helper_spec.rb @@ -42,6 +42,7 @@ describe NavHelper, :do_not_mock_admin_mode do context 'with admin mode enabled' do before do + current_user_mode.request_admin_mode! current_user_mode.enable_admin_mode!(password: user.password) end @@ -62,6 +63,7 @@ describe NavHelper, :do_not_mock_admin_mode do context 'with admin mode enabled' do before do + current_user_mode.request_admin_mode! current_user_mode.enable_admin_mode!(password: user.password) end @@ -89,11 +91,18 @@ describe NavHelper, :do_not_mock_admin_mode do end end - it 'returns only the sign in and search when the user is not logged in' do - allow(helper).to receive(:current_user).and_return(nil) - allow(helper).to receive(:can?).with(nil, :read_cross_project) { true } + context 'when the user is not logged in' do + let(:current_user_mode) { Gitlab::Auth::CurrentUserMode.new(nil) } - expect(helper.header_links).to contain_exactly(:sign_in, :search) + before do + allow(helper).to receive(:current_user).and_return(nil) + allow(helper).to receive(:current_user_mode).and_return(current_user_mode) + allow(helper).to receive(:can?).with(nil, :read_cross_project) { true } + end + + it 'returns only the sign in and search when the user is not logged in' do + expect(helper.header_links).to contain_exactly(:sign_in, :search) + end end end |