debian-mirror-gitlab/spec/features/projects/settings/registry_settings_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

100 lines
3.2 KiB
Ruby
Raw Normal View History

2020-03-13 15:44:24 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-03-04 22:38:38 +05:30
RSpec.describe 'Project > Settings > Packages and registries > Container registry tag expiration policy',
feature_category: :projects do
2021-01-03 14:25:43 +05:30
let_it_be(:user) { create(:user) }
let_it_be(:project, reload: true) { create(:project, namespace: user.namespace) }
2020-03-13 15:44:24 +05:30
let(:container_registry_enabled) { true }
2021-10-27 15:23:28 +05:30
let(:container_registry_enabled_on_project) { ProjectFeature::ENABLED }
2021-01-03 14:25:43 +05:30
2021-09-30 23:02:18 +05:30
subject { visit project_settings_packages_and_registries_path(project) }
2020-03-13 15:44:24 +05:30
2021-09-30 23:02:18 +05:30
before do
2021-10-27 15:23:28 +05:30
project.project_feature.update!(container_registry_access_level: container_registry_enabled_on_project)
2021-09-30 23:02:18 +05:30
project.container_expiration_policy.update!(enabled: true)
2021-01-03 14:25:43 +05:30
2021-09-30 23:02:18 +05:30
sign_in(user)
stub_container_registry_config(enabled: container_registry_enabled)
end
2021-01-03 14:25:43 +05:30
2022-10-11 01:57:18 +05:30
context 'as owner', :js do
it 'shows active tab on sidebar' do
2021-09-30 23:02:18 +05:30
subject
2021-02-22 17:27:13 +05:30
2022-10-11 01:57:18 +05:30
expect(find('.sidebar-top-level-items > li.active')).to have_content('Settings')
expect(find('.sidebar-sub-level-items > li.active:not(.fly-out-top-item)'))
.to have_content('Packages and registries')
2021-09-30 23:02:18 +05:30
end
2021-06-08 01:23:25 +05:30
2022-10-11 01:57:18 +05:30
it 'shows available section' do
2021-09-30 23:02:18 +05:30
subject
2021-06-08 01:23:25 +05:30
2022-10-11 01:57:18 +05:30
settings_block = find('[data-testid="container-expiration-policy-project-settings"]')
expect(settings_block).to have_text 'Clean up image tags'
2020-03-13 15:44:24 +05:30
end
2020-06-23 00:09:42 +05:30
2022-10-11 01:57:18 +05:30
it 'contains link to clean up image tags page' do
2021-09-30 23:02:18 +05:30
subject
2021-01-03 14:25:43 +05:30
2022-10-11 01:57:18 +05:30
expect(page).to have_link('Edit cleanup rules', href: cleanup_image_tags_project_settings_packages_and_registries_path(project))
2021-09-30 23:02:18 +05:30
end
end
2020-03-13 15:44:24 +05:30
2022-10-11 01:57:18 +05:30
context 'with a project without expiration policy', :js do
2022-05-07 20:08:51 +05:30
before do
project.container_expiration_policy.destroy!
end
context 'with container_expiration_policies_enable_historic_entries enabled' do
before do
stub_application_setting(container_expiration_policies_enable_historic_entries: true)
end
it 'displays the related section' do
subject
2022-08-13 15:12:31 +05:30
within '[data-testid="container-expiration-policy-project-settings"]' do
2022-10-11 01:57:18 +05:30
expect(page).to have_link('Set cleanup rules', href: cleanup_image_tags_project_settings_packages_and_registries_path(project))
2022-05-07 20:08:51 +05:30
end
end
2021-06-08 01:23:25 +05:30
end
2021-01-03 14:25:43 +05:30
2022-05-07 20:08:51 +05:30
context 'with container_expiration_policies_enable_historic_entries disabled' do
2021-09-30 23:02:18 +05:30
before do
2022-05-07 20:08:51 +05:30
stub_application_setting(container_expiration_policies_enable_historic_entries: false)
2021-09-30 23:02:18 +05:30
end
2021-06-08 01:23:25 +05:30
2022-05-07 20:08:51 +05:30
it 'does not display the related section' do
2021-01-03 14:25:43 +05:30
subject
2022-08-13 15:12:31 +05:30
within '[data-testid="container-expiration-policy-project-settings"]' do
2022-05-07 20:08:51 +05:30
expect(find('.gl-alert-title')).to have_content('Cleanup policy for tags is disabled')
2021-09-30 23:02:18 +05:30
end
2021-01-03 14:25:43 +05:30
end
2020-03-13 15:44:24 +05:30
end
end
2021-09-30 23:02:18 +05:30
context 'when registry is disabled' do
let(:container_registry_enabled) { false }
2020-03-13 15:44:24 +05:30
2021-09-30 23:02:18 +05:30
it 'does not exists' do
subject
2021-01-03 14:25:43 +05:30
2022-08-13 15:12:31 +05:30
expect(page).not_to have_selector('[data-testid="container-expiration-policy-project-settings"]')
2021-09-30 23:02:18 +05:30
end
2021-06-08 01:23:25 +05:30
end
2020-03-13 15:44:24 +05:30
2021-09-30 23:02:18 +05:30
context 'when container registry is disabled on project' do
2021-10-27 15:23:28 +05:30
let(:container_registry_enabled_on_project) { ProjectFeature::DISABLED }
2021-01-03 14:25:43 +05:30
2021-09-30 23:02:18 +05:30
it 'does not exists' do
subject
2021-06-08 01:23:25 +05:30
2022-08-13 15:12:31 +05:30
expect(page).not_to have_selector('[data-testid="container-expiration-policy-project-settings"]')
2021-09-30 23:02:18 +05:30
end
2020-03-13 15:44:24 +05:30
end
end