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

68 lines
1.9 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
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
2018-11-08 19:23:39 +05:30
it 'user removes entire container repository' 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-10-12 21:52:04 +05:30
expect_any_instance_of(ContainerRegistry::Tag).to receive(:delete).and_return(true)
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-09-30 21:07:59 +05:30
expect(find('.modal .modal-title')).to have_content 'Remove image'
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