debian-mirror-gitlab/spec/features/container_registry_spec.rb

75 lines
2.2 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2016-06-02 11:05:42 +05:30
require 'spec_helper'
2019-10-12 21:52:04 +05:30
describe 'Container Registry', :js do
2017-08-17 22:00:37 +05:30
let(:user) { create(:user) }
2017-09-10 17:25:29 +05:30
let(:project) { create(:project) }
2017-08-17 22:00:37 +05:30
let(:container_repository) do
create(:container_repository, name: 'my/image')
end
2016-06-02 11:05:42 +05:30
before do
2017-09-10 17:25:29 +05:30
sign_in(user)
2017-08-17 22:00:37 +05:30
project.add_developer(user)
2016-06-02 11:05:42 +05:30
stub_container_registry_config(enabled: true)
2017-08-17 22:00:37 +05:30
stub_container_registry_tags(repository: :any, tags: [])
2016-06-02 11:05:42 +05:30
end
2019-12-21 20:55:43 +05:30
it 'has a page title set' do
visit_container_registry
expect(page).to have_title(_('Container Registry'))
end
2017-08-17 22:00:37 +05:30
context 'when there are no image repositories' do
2018-11-08 19:23:39 +05:30
it 'user visits container registry main page' do
2017-08-17 22:00:37 +05:30
visit_container_registry
2019-09-30 21:07:59 +05:30
expect(page).to have_content 'no container images'
2017-08-17 22:00:37 +05:30
end
end
context 'when there are image repositories' do
2016-06-02 11:05:42 +05:30
before do
2019-03-02 22:35:43 +05:30
stub_container_registry_tags(repository: %r{my/image}, tags: %w[latest], with_manifest: true)
2017-08-17 22:00:37 +05:30
project.container_repositories << container_repository
2016-06-02 11:05:42 +05:30
end
2018-11-08 19:23:39 +05:30
it 'user wants to see multi-level container repository' do
2017-08-17 22:00:37 +05:30
visit_container_registry
2016-06-02 11:05:42 +05:30
2017-08-17 22:00:37 +05:30
expect(page).to have_content('my/image')
2016-06-02 11:05:42 +05:30
end
2019-12-26 22:10:19 +05:30
it 'user removes entire container repository', :sidekiq_might_not_need_inline do
2017-08-17 22:00:37 +05:30
visit_container_registry
2016-06-02 11:05:42 +05:30
2019-10-12 21:52:04 +05:30
expect_any_instance_of(ContainerRepository).to receive(:delete_tags!).and_return(true)
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
click_on(class: 'js-remove-repo')
2019-09-30 21:07:59 +05:30
expect(find('.modal .modal-title')).to have_content 'Remove repository'
find('.modal .modal-footer .btn-danger').click
2016-06-02 11:05:42 +05:30
end
2018-11-08 19:23:39 +05:30
it 'user removes a specific tag from container repository' do
2017-08-17 22:00:37 +05:30
visit_container_registry
2016-06-02 11:05:42 +05:30
2018-03-17 18:26:18 +05:30
find('.js-toggle-repo').click
wait_for_requests
2019-12-21 20:55:43 +05:30
service = double('service')
expect(service).to receive(:execute).with(container_repository) { { status: :success } }
expect(Projects::ContainerRepository::DeleteTagsService).to receive(:new).with(container_repository.project, user, tags: ['latest']) { service }
2017-08-17 22:00:37 +05:30
2019-10-12 21:52:04 +05:30
click_on(class: 'js-delete-registry-row', visible: false)
2019-12-21 20:55:43 +05:30
expect(find('.modal .modal-title')).to have_content 'Remove tag'
2019-09-30 21:07:59 +05:30
find('.modal .modal-footer .btn-danger').click
2016-06-02 11:05:42 +05:30
end
end
2017-08-17 22:00:37 +05:30
def visit_container_registry
2017-09-10 17:25:29 +05:30
visit project_container_registry_index_path(project)
2017-08-17 22:00:37 +05:30
end
2016-06-02 11:05:42 +05:30
end