diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
commit | 4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch) | |
tree | 5423a1c7516cffe36384133ade12572cf709398d /spec/features/projects/settings/registry_settings_spec.rb | |
parent | e570267f2f6b326480d284e0164a6464ba4081bc (diff) |
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'spec/features/projects/settings/registry_settings_spec.rb')
-rw-r--r-- | spec/features/projects/settings/registry_settings_spec.rb | 160 |
1 files changed, 90 insertions, 70 deletions
diff --git a/spec/features/projects/settings/registry_settings_spec.rb b/spec/features/projects/settings/registry_settings_spec.rb index bc60cdd2f8e..6a2769d11fd 100644 --- a/spec/features/projects/settings/registry_settings_spec.rb +++ b/spec/features/projects/settings/registry_settings_spec.rb @@ -11,105 +11,125 @@ RSpec.describe 'Project > Settings > CI/CD > Container registry tag expiration p let(:container_registry_enabled) { true } let(:container_registry_enabled_on_project) { true } - subject { visit project_settings_ci_cd_path(project) } + shared_examples 'an expiration policy form' do + before do + project.update!(container_registry_enabled: container_registry_enabled_on_project) + project.container_expiration_policy.update!(enabled: true) - before do - project.update!(container_registry_enabled: container_registry_enabled_on_project) - project.container_expiration_policy.update!(enabled: true) + sign_in(user) + stub_container_registry_config(enabled: container_registry_enabled) + end - sign_in(user) - stub_container_registry_config(enabled: container_registry_enabled) - end + context 'as owner' do + it 'shows available section' do + subject - context 'as owner' do - it 'shows available section' do - subject + settings_block = find('#js-registry-policies') + expect(settings_block).to have_text 'Clean up image tags' + end - settings_block = find('#js-registry-policies') - expect(settings_block).to have_text 'Clean up image tags' - end + it 'saves cleanup policy submit the form' do + subject - it 'saves cleanup policy submit the form' do - subject + within '#js-registry-policies' do + select('Every day', from: 'Run cleanup') + select('50 tags per image name', from: 'Keep the most recent:') + fill_in('Keep tags matching:', with: 'stable') + select('7 days', from: 'Remove tags older than:') + fill_in('Remove tags matching:', with: '.*-production') + + submit_button = find('[data-testid="save-button"') + expect(submit_button).not_to be_disabled + submit_button.click + end - within '#js-registry-policies' do - select('Every day', from: 'Run cleanup') - select('50 tags per image name', from: 'Keep the most recent:') - fill_in('Keep tags matching:', with: 'stable') - select('7 days', from: 'Remove tags older than:') - fill_in('Remove tags matching:', with: '.*-production') + expect(find('.gl-toast')).to have_content('Cleanup policy successfully saved.') + end - submit_button = find('[data-testid="save-button"') - expect(submit_button).not_to be_disabled - submit_button.click + it 'does not save cleanup policy submit form with invalid regex' do + subject + + within '#js-registry-policies' do + fill_in('Remove tags matching:', with: '*-production') + + submit_button = find('[data-testid="save-button"') + expect(submit_button).not_to be_disabled + submit_button.click + end + + expect(find('.gl-toast')).to have_content('Something went wrong while updating the cleanup policy.') end - toast = find('.gl-toast') - expect(toast).to have_content('Cleanup policy successfully saved.') end - it 'does not save cleanup policy submit form with invalid regex' do - subject + context 'with a project without expiration policy' do + where(:application_setting, :feature_flag, :result) do + true | true | :available_section + true | false | :available_section + false | true | :available_section + false | false | :disabled_message + end - within '#js-registry-policies' do - fill_in('Remove tags matching:', with: '*-production') + with_them do + before do + project.container_expiration_policy.destroy! + stub_feature_flags(container_expiration_policies_historic_entry: false) + stub_application_setting(container_expiration_policies_enable_historic_entries: application_setting) + stub_feature_flags(container_expiration_policies_historic_entry: project) if feature_flag + end - submit_button = find('[data-testid="save-button"') - expect(submit_button).not_to be_disabled - submit_button.click + it 'displays the expected result' do + subject + + within '#js-registry-policies' do + case result + when :available_section + expect(find('[data-testid="enable-toggle"]')).to have_content('Disabled - Tags will not be automatically deleted.') + when :disabled_message + expect(find('.gl-alert-title')).to have_content('Cleanup policy for tags is disabled') + end + end + end end - toast = find('.gl-toast') - expect(toast).to have_content('Something went wrong while updating the cleanup policy.') end - end - context 'with a project without expiration policy' do - where(:application_setting, :feature_flag, :result) do - true | true | :available_section - true | false | :available_section - false | true | :available_section - false | false | :disabled_message - end + context 'when registry is disabled' do + let(:container_registry_enabled) { false } + + it 'does not exists' do + subject - with_them do - before do - project.container_expiration_policy.destroy! - stub_feature_flags(container_expiration_policies_historic_entry: false) - stub_application_setting(container_expiration_policies_enable_historic_entries: application_setting) - stub_feature_flags(container_expiration_policies_historic_entry: project) if feature_flag + expect(page).not_to have_selector('#js-registry-policies') end + end - it 'displays the expected result' do + context 'when container registry is disabled on project' do + let(:container_registry_enabled_on_project) { false } + + it 'does not exists' do subject - within '#js-registry-policies' do - case result - when :available_section - expect(find('[data-testid="enable-toggle"]')).to have_content('Disabled - Tags will not be automatically deleted.') - when :disabled_message - expect(find('.gl-alert-title')).to have_content('Cleanup policy for tags is disabled') - end - end + expect(page).not_to have_selector('#js-registry-policies') end end end - context 'when registry is disabled' do - let(:container_registry_enabled) { false } + context 'with sidebar feature flag off' do + subject { visit project_settings_ci_cd_path(project) } - it 'does not exists' do - subject - - expect(page).not_to have_selector('#js-registry-policies') + before do + stub_feature_flags(sidebar_refactor: false) end - end - context 'when container registry is disabled on project' do - let(:container_registry_enabled_on_project) { false } + it_behaves_like 'an expiration policy form' + end - it 'does not exists' do - subject + context 'with sidebar feature flag on' do + subject { visit project_settings_packages_and_registries_path(project) } - expect(page).not_to have_selector('#js-registry-policies') + before do + stub_feature_flags(sidebar_refactor: true) end + + it_behaves_like 'an expiration policy form' end end |