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

79 lines
2.5 KiB
Ruby
Raw Normal View History

2020-03-13 15:44:24 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-06-23 00:09:42 +05:30
RSpec.describe 'Project > Settings > CI/CD > Container registry tag expiration policy', :js do
2020-03-13 15:44:24 +05:30
let(:user) { create(:user) }
let(:project) { create(:project, namespace: user.namespace, container_registry_enabled: container_registry_enabled) }
let(:container_registry_enabled) { true }
before do
sign_in(user)
stub_container_registry_config(enabled: true)
2020-04-08 14:13:33 +05:30
stub_feature_flags(new_variables_ui: false)
2020-03-13 15:44:24 +05:30
end
context 'as owner' do
before do
visit project_settings_ci_cd_path(project)
end
it 'shows available section' do
settings_block = find('#js-registry-policies')
2020-07-28 23:09:34 +05:30
expect(settings_block).to have_text 'Cleanup policy for tags'
2020-03-13 15:44:24 +05:30
end
2020-07-28 23:09:34 +05:30
it 'saves cleanup policy submit the form' do
2020-03-13 15:44:24 +05:30
within '#js-registry-policies' do
within '.card-body' do
select('7 days until tags are automatically removed', from: 'Expiration interval:')
select('Every day', from: 'Expiration schedule:')
select('50 tags per image name', from: 'Number of tags to retain:')
2020-06-23 00:09:42 +05:30
fill_in('Tags with names matching this regex pattern will expire:', with: '.*-production')
2020-03-13 15:44:24 +05:30
end
submit_button = find('.card-footer .btn.btn-success')
expect(submit_button).not_to be_disabled
submit_button.click
end
toast = find('.gl-toast')
2020-07-28 23:09:34 +05:30
expect(toast).to have_content('Cleanup policy successfully saved.')
2020-03-13 15:44:24 +05:30
end
2020-06-23 00:09:42 +05:30
2020-07-28 23:09:34 +05:30
it 'does not save cleanup policy submit form with invalid regex' do
2020-06-23 00:09:42 +05:30
within '#js-registry-policies' do
within '.card-body' do
fill_in('Tags with names matching this regex pattern will expire:', with: '*-production')
end
submit_button = find('.card-footer .btn.btn-success')
expect(submit_button).not_to be_disabled
submit_button.click
end
toast = find('.gl-toast')
2020-07-28 23:09:34 +05:30
expect(toast).to have_content('Something went wrong while updating the cleanup policy.')
2020-06-23 00:09:42 +05:30
end
2020-03-13 15:44:24 +05:30
end
context 'when registry is disabled' do
before do
stub_container_registry_config(enabled: false)
visit project_settings_ci_cd_path(project)
end
it 'does not exists' do
expect(page).not_to have_selector('#js-registry-policies')
end
end
context 'when container registry is disabled on project' do
let(:container_registry_enabled) { false }
before do
visit project_settings_ci_cd_path(project)
end
it 'does not exists' do
expect(page).not_to have_selector('#js-registry-policies')
end
end
end