2016-06-02 11:05:42 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe "Container Registry" 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
|
|
|
|
scenario 'user visits container registry main page' do
|
|
|
|
visit_container_registry
|
|
|
|
|
2017-09-10 17:25:29 +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
|
2017-08-17 22:00:37 +05:30
|
|
|
stub_container_registry_tags(repository: %r{my/image}, tags: %w[latest])
|
|
|
|
project.container_repositories << container_repository
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
scenario 'user wants to see multi-level container repository' do
|
|
|
|
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
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
scenario 'user removes entire container repository' do
|
|
|
|
visit_container_registry
|
2016-06-02 11:05:42 +05:30
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
expect_any_instance_of(ContainerRepository)
|
|
|
|
.to receive(:delete_tags!).and_return(true)
|
|
|
|
|
|
|
|
click_on 'Remove repository'
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
scenario 'user removes a specific tag from container repository' do
|
|
|
|
visit_container_registry
|
2016-06-02 11:05:42 +05:30
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
expect_any_instance_of(ContainerRegistry::Tag)
|
|
|
|
.to receive(:delete).and_return(true)
|
|
|
|
|
|
|
|
click_on 'Remove tag'
|
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
|