GitLab steht Mittwoch, den 23. September, zwischen 10:00 und 12:00 Uhr aufgrund von Wartungsarbeiten nicht zur Verfügung.

Commit 662d2e68 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Refactor feature specs for container registry

parent fc550b39
......@@ -29,6 +29,6 @@
= link_to namespace_project_registry_repository_tag_path(@project.namespace, @project, tag.repository, tag.name),
method: :delete,
class: 'btn btn-remove has-tooltip',
title: 'Remove image tag',
title: 'Remove tag',
data: { confirm: notice } do
= icon('trash cred')
require 'spec_helper'
describe "Container Registry" do
let(:user) { create(:user) }
let(:project) { create(:empty_project) }
let(:registry) { project.container_registry }
let(:tag_name) { 'latest' }
let(:tags) { [tag_name] }
let(:container_repository) { create(:container_repository) }
let(:image_name) { container_repository.name }
let(:container_repository) do
create(:container_repository, name: 'my/image')
end
before do
login_as(:user)
project.team << [@user, :developer]
login_as(user)
project.add_developer(user)
stub_container_registry_config(enabled: true)
stub_container_registry_tags(*tags)
project.container_repositories << container_repository unless container_repository.nil?
stub_container_registry_tags(%w[latest])
end
describe 'GET /:project/container_registry' do
before do
visit namespace_project_container_registry_index_path(project.namespace, project)
end
context 'when no images' do
let(:container_repository) { }
it { expect(page).to have_content('No container images in Container Registry for this project') }
end
context 'when there are no image repositories' do
scenario 'user visits container registry main page' do
visit_container_registry
context 'when there are images' do
it { expect(page).to have_content(image_name) }
expect(page).to have_content 'No container images'
end
end
describe 'DELETE /:project/container_registry/:image_id' do
context 'when there are image repositories' do
before do
visit namespace_project_container_registry_index_path(project.namespace, project)
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')
end
it do
scenario 'user removes entire container repository' do
visit_container_registry
expect_any_instance_of(ContainerRepository)
.to receive(:delete_tags!).and_return(true)
click_on 'Remove image'
click_on 'Remove repository'
end
end
describe 'DELETE /:project/container_registry/tag' do
before do
visit namespace_project_container_registry_index_path(project.namespace, project)
end
scenario 'user removes a specific tag from container repository' do
visit_container_registry
it do
expect_any_instance_of(::ContainerRegistry::Tag).to receive(:delete).and_return(true)
expect_any_instance_of(ContainerRegistry::Tag)
.to receive(:delete).and_return(true)
click_on 'Remove tag'
end
end
def visit_container_registry
visit namespace_project_container_registry_index_path(
project.namespace, project)
end
end
......@@ -32,15 +32,15 @@ module StubGitlabCalls
end
def stub_container_registry_tags(*tags)
allow_any_instance_of(ContainerRegistry::Client).to receive(:repository_tags).and_return(
{ "tags" => tags }
)
allow_any_instance_of(ContainerRegistry::Client).to receive(:repository_manifest).and_return(
JSON.parse(File.read(Rails.root + 'spec/fixtures/container_registry/tag_manifest.json'))
)
allow_any_instance_of(ContainerRegistry::Client)
.to receive(:repository_tags).and_return({ 'tags' => tags })
allow_any_instance_of(ContainerRegistry::Client)
.to receive(:repository_manifest).and_return(
JSON.parse(File.read(Rails.root + 'spec/fixtures/container_registry/tag_manifest.json')))
allow_any_instance_of(ContainerRegistry::Client).to receive(:blob).and_return(
File.read(Rails.root + 'spec/fixtures/container_registry/config_blob.json')
)
File.read(Rails.root + 'spec/fixtures/container_registry/config_blob.json'))
end
private
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment