2016-05-09 16:32:18 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe "Container Registry" do
|
2017-04-03 04:38:37 -04:00
|
|
|
let(:user) { create(:user) }
|
2016-05-09 16:32:18 -04:00
|
|
|
let(:project) { create(:empty_project) }
|
2017-04-03 04:38:37 -04:00
|
|
|
|
|
|
|
let(:container_repository) do
|
|
|
|
create(:container_repository, name: 'my/image')
|
|
|
|
end
|
2016-05-09 16:32:18 -04:00
|
|
|
|
|
|
|
before do
|
2017-04-03 04:38:37 -04:00
|
|
|
login_as(user)
|
|
|
|
project.add_developer(user)
|
2016-05-16 19:07:49 -04:00
|
|
|
stub_container_registry_config(enabled: true)
|
2017-04-03 09:52:24 -04:00
|
|
|
stub_container_registry_tags(repository: :any, tags: [])
|
2016-05-09 16:32:18 -04:00
|
|
|
end
|
|
|
|
|
2017-04-03 04:38:37 -04:00
|
|
|
context 'when there are no image repositories' do
|
|
|
|
scenario 'user visits container registry main page' do
|
|
|
|
visit_container_registry
|
2016-05-12 14:03:04 -04:00
|
|
|
|
2017-04-04 08:58:51 -04:00
|
|
|
expect(page).to have_content 'No container image repositories'
|
2016-05-09 16:32:18 -04:00
|
|
|
end
|
2016-12-15 22:24:05 -05:00
|
|
|
end
|
|
|
|
|
2017-04-03 04:38:37 -04:00
|
|
|
context 'when there are image repositories' do
|
2016-12-15 22:24:05 -05:00
|
|
|
before do
|
2017-04-03 09:52:24 -04:00
|
|
|
stub_container_registry_tags(repository: %r{my/image}, tags: %w[latest])
|
2017-04-03 04:38:37 -04:00
|
|
|
project.container_repositories << container_repository
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'user wants to see multi-level container repository' do
|
|
|
|
visit_container_registry
|
|
|
|
|
|
|
|
expect(page).to have_content('my/image')
|
2016-12-15 22:24:05 -05:00
|
|
|
end
|
|
|
|
|
2017-04-03 04:38:37 -04:00
|
|
|
scenario 'user removes entire container repository' do
|
|
|
|
visit_container_registry
|
|
|
|
|
2017-03-31 05:54:09 -04:00
|
|
|
expect_any_instance_of(ContainerRepository)
|
|
|
|
.to receive(:delete_tags!).and_return(true)
|
2016-05-09 16:32:18 -04:00
|
|
|
|
2017-04-03 04:38:37 -04:00
|
|
|
click_on 'Remove repository'
|
2016-05-09 16:32:18 -04:00
|
|
|
end
|
|
|
|
|
2017-04-03 04:38:37 -04:00
|
|
|
scenario 'user removes a specific tag from container repository' do
|
|
|
|
visit_container_registry
|
2016-05-09 16:32:18 -04:00
|
|
|
|
2017-04-03 04:38:37 -04:00
|
|
|
expect_any_instance_of(ContainerRegistry::Tag)
|
|
|
|
.to receive(:delete).and_return(true)
|
2016-05-12 14:03:04 -04:00
|
|
|
|
2016-12-15 22:24:05 -05:00
|
|
|
click_on 'Remove tag'
|
2016-05-09 16:32:18 -04:00
|
|
|
end
|
|
|
|
end
|
2017-04-03 04:38:37 -04:00
|
|
|
|
|
|
|
def visit_container_registry
|
|
|
|
visit namespace_project_container_registry_index_path(
|
|
|
|
project.namespace, project)
|
|
|
|
end
|
2016-05-12 14:03:04 -04:00
|
|
|
end
|